Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5dd7481
updating README and gitignore for Python
SuperFola Jul 18, 2021
73cb423
setting up base Python project
SuperFola Jul 18, 2021
8ae5a9b
adding GitHub action linter
SuperFola Jul 18, 2021
b428e84
merging with master
SuperFola Jul 18, 2021
1c6b4d2
adding a virtual environment
SuperFola Jul 18, 2021
c726807
adding a basic logger
SuperFola Jul 18, 2021
235b7ca
adding argument [source_folder]
SuperFola Jul 18, 2021
96c8c89
adding a very basic WIP parser
SuperFola Jul 18, 2021
927adb3
renaming logger.py to logger_utils.py
SuperFola Jul 18, 2021
c82dd39
adding a file explorer and reader
SuperFola Jul 18, 2021
d62c170
adding a generator module plus the specification
SuperFola Jul 18, 2021
395f59f
enhancing generator and adding basic WIP template
SuperFola Jul 18, 2021
14cddc0
updating python requirements
SuperFola Jul 18, 2021
3b203b3
adding more files for the templates
SuperFola Jul 18, 2021
bb981a6
enhancing the parser's tokenizer
SuperFola Jul 18, 2021
3ac4796
fixing parser and better tokenizer
SuperFola Jul 18, 2021
c6bdd30
cleaning the parser code and adding a documentation extractor
SuperFola Jul 18, 2021
f7a4aa7
adding documentation extraction
SuperFola Jul 18, 2021
6edec06
removing debug code
SuperFola Jul 18, 2021
6586432
improving documentation generator
SuperFola Jul 18, 2021
ad96bbb
tidying the code and adding more options to the cli
SuperFola Jul 18, 2021
4ec30d9
adding toggle to parse documentation comments from the builtins
SuperFola Jul 18, 2021
3a5d504
updating base generator to merge files with the same name (ignoring t…
SuperFola Jul 18, 2021
8847d0b
fixing workflow
SuperFola Jul 18, 2021
3887218
linter
SuperFola Jul 18, 2021
f0809de
adding test workflow
SuperFola Jul 18, 2021
ae5dbed
handling multiple authors
SuperFola Jul 18, 2021
99654a3
enhancing the C++ tokenizer and adding more details about the syntax
SuperFola Jul 20, 2021
da0e86f
removing @meta for now
SuperFola Jul 20, 2021
2b4c3ea
fixing the cpp doxygen comment extractor
SuperFola Jul 24, 2021
105cbea
adding argument to --html option to put the generated files in it
SuperFola Jul 24, 2021
2211d97
get loglevel from an environment variable
SuperFola Jul 24, 2021
f1034b9
add info on loglevel on the readme
SuperFola Jul 24, 2021
534e352
starting the generation of the html documentation
SuperFola Jul 24, 2021
837ab5e
enhancing the html generator
SuperFola Jul 24, 2021
2204563
finalizing the html generator, adding a table of contents
SuperFola Jul 24, 2021
a777717
adding an argument to specify the target arkscript version
SuperFola Jul 24, 2021
2690496
updating the ci to use the latest arkdoc cli
SuperFola Jul 24, 2021
c0eaea1
do not validate css/html
SuperFola Jul 24, 2021
cc59944
fixing test.yml workflow
SuperFola Jul 24, 2021
16239ac
mutualising code
SuperFola Jul 24, 2021
d6ca692
fixing github action linter
SuperFola Jul 24, 2021
1207ced
formatting code
SuperFola Jul 24, 2021
3b48d1c
fixing the generator to avoid listing an empty author
SuperFola Jul 31, 2021
dbdc9b9
do not display the parameter section if the function doesn't take any
SuperFola Aug 1, 2021
89fbc5e
adding a root-dir parameter so that we can generate the output wherev…
SuperFola Aug 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adding a root-dir parameter so that we can generate the output wherev…
…er we want
  • Loading branch information
SuperFola committed Aug 1, 2021
commit 89fbc5e7cc71c534cc41918fa5e1e9d40412cc5d
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- run: pip install -r requirements.txt
- run: |
export ARKDOC_LOGLEVEL=DEBUG
python -m arkdoc 3.1.0 std-latest/ --builtins ark-latest/src/Builtins --html out || exit 1
python -m arkdoc 3.1.0 std-latest/ ark-latest/src/Builtins --html out || exit 1
23 changes: 12 additions & 11 deletions arkdoc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
def compute(args) -> bool:
global logger

if not os.path.exists(args.source_folder):
logger.error(f"Folder `${args.source_folder}` does not exists")
return False
for folder in args.source_folder:
if not os.path.exists(folder):
logger.error(f"Folder `{folder}` does not exists")
return False

if args.dry_run:
logger.level = LogLevel.DEBUG

parsers = parse_all_in(args.source_folder)
if args.builtins:
parsers += parse_all_in(args.builtins)
parsers = []
for folder in args.source_folder:
parsers += parse_all_in(folder)
for p in parsers:
logger.info(f"Parsing {p.filename}...")
p.parse()
Expand All @@ -36,7 +37,7 @@ def compute(args) -> bool:

if not args.dry_run:
if args.html:
gen = HTMLGenerator(parsers, args.html, args.ark_version)
gen = HTMLGenerator(parsers, args.html, args.ark_version, args.root_dir)
gen()
else:
logger.error("Missing generator!")
Expand All @@ -49,17 +50,17 @@ def main() -> int:
cli = argparse.ArgumentParser(description="ArkScript Documentation generator")
cli.add_argument("ark_version", type=str, help="ArkScript version number, eg 3.1.0")
cli.add_argument(
"source_folder", type=str, help="Path to the ArkScript source folder"
)
cli.add_argument(
"--builtins", type=str, help="Path to the builtins folder", default=None
"source_folder", type=str, help="Path to the ArkScript source folder", nargs="+"
)
cli.add_argument(
"--dry-run",
action="store_true",
help="Run and log everything but don't generate any file",
)
cli.add_argument("--html", type=str, help="Output folder for the HTML docs")
cli.add_argument(
"--root-dir", type=str, default="", help="The root dir for the links"
)

args = cli.parse_args()

Expand Down
4 changes: 3 additions & 1 deletion arkdoc/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ def __init__(
pattern: str,
output: str,
ark_version: str,
root: str,
):
self.template_folder = template_folder
self.templates = {
file.name: file.read_text("utf-8") for file in template_folder.glob(pattern)
}
self.version = ark_version
self.output_path = Path(output)
self.version = ark_version
self.output_path_ver = self.output_path / self.version
self.root = root if root and root[-1] != "/" else root[:-1]
self.list = spec.FileList([])
self._create_files_list(parsers)

Expand Down
14 changes: 8 additions & 6 deletions arkdoc/generator/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def h4(name: str) -> str:


class HTMLGenerator(Generator):
def __init__(self, parsers: List[Parser], output: str, ark_version: str):
def __init__(self, parsers: List[Parser], output: str, ark_version: str, root: str):
super().__init__(
parsers, spec.HTML_TEMPLATE_FOLDER, "*.html", output, ark_version
parsers, spec.HTML_TEMPLATE_FOLDER, "*.html", output, ark_version, root
)

self.footer = f"<i>Last generation at {datetime.now()}</i>"
Expand All @@ -111,18 +111,19 @@ def generate_index(self):
f"Welcome! This is the official documentation for ArkScript {self.version}"
+ html.ul(
[
html.a(file.path, f"/{self.version}/{file.path}.html")
html.a(file.path, f"{self.root}/{self.version}/{file.path}.html")
for file in self.list.files
]
),
)

content = self.templates["index.html"]
content = content.format(
root=self.root,
page_title=f"ArkScript {self.version} documentation",
home_link=f"/{self.version}",
home_link=f"{self.root}/{self.version}",
has_banner="has-banner",
banner=self.templates["banner.html"],
banner=self.templates["banner.html"].format(root=self.root),
table_of_content="",
navigation_links="",
sections=sections,
Expand Down Expand Up @@ -180,8 +181,9 @@ def generate_one(self, path: str, functions: List[spec.Function]):

content = self.templates["index.html"]
content = content.format(
root=self.root,
page_title=f"{path} - ArkScript {self.version} documentation",
home_link=f"/{self.version}",
home_link=f"{self.root}/{self.version}",
has_banner="",
banner="",
table_of_content=table_of_content,
Expand Down
2 changes: 1 addition & 1 deletion templates/banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<section class="navbar-center">
<div class="banner-center">
<figure class="figure">
<img class="img-responsive" src="/assets/images/Ark-slim.png" alt="ArkScript">
<img class="img-responsive" src="{root}/assets/images/Ark-slim.png" alt="ArkScript">
<figcaption class="figure-caption navbar-brand">ArkScript</figcaption>
</figure>
</div>
Expand Down
16 changes: 8 additions & 8 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<head>
<meta charset="UTF-8">
<title>{page_title}</title>
<link rel="stylesheet" href="/assets/css/spectre.min.css" type="text/css">
<link rel="stylesheet" href="/assets/css/spectre-exp.min.css" type="text/css">
<link rel="stylesheet" href="/assets/css/spectre-icons.min.css" type="text/css">
<link rel="stylesheet" href="/assets/css/rainbowjs-theme.css" type="text/css">
<link rel="stylesheet" href="/assets/css/main.css" type="text/css">
<link rel="stylesheet" href="{root}/assets/css/spectre.min.css" type="text/css">
<link rel="stylesheet" href="{root}/assets/css/spectre-exp.min.css" type="text/css">
<link rel="stylesheet" href="{root}/assets/css/spectre-icons.min.css" type="text/css">
<link rel="stylesheet" href="{root}/assets/css/rainbowjs-theme.css" type="text/css">
<link rel="stylesheet" href="{root}/assets/css/main.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
Expand All @@ -27,7 +27,7 @@
<a href="https://discord.gg/YT5yDwn" target="_blank" class="btn btn-link">Discord</a>
</section>
<section class="navbar-section logo">
<a href="/" class="hide"><img src="/assets/images/Ark-slim.png" alt="ArkScript"></a>
<a href="{root}/" class="hide"><img src="{root}/assets/images/Ark-slim.png" alt="ArkScript"></a>
</section>
</header>

Expand Down Expand Up @@ -60,8 +60,8 @@
</footer>

<!-- Rainbow.js for syntax coloring -->
<script src="/assets/js/rainbow.min.js"></script>
<script src="/assets/js/languages/arkscript.js"></script>
<script src="{root}/assets/js/rainbow.min.js"></script>
<script src="{root}/assets/js/languages/arkscript.js"></script>
</body>

</html>