diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 416c518..e833838 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 \ No newline at end of file + python -m arkdoc 3.1.0 std-latest/ ark-latest/src/Builtins --html out || exit 1 \ No newline at end of file diff --git a/arkdoc/__main__.py b/arkdoc/__main__.py index fd94e27..ce4f78a 100644 --- a/arkdoc/__main__.py +++ b/arkdoc/__main__.py @@ -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() @@ -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!") @@ -49,10 +50,7 @@ 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", @@ -60,6 +58,9 @@ def main() -> int: 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() diff --git a/arkdoc/generator/base.py b/arkdoc/generator/base.py index 0676011..d994a03 100644 --- a/arkdoc/generator/base.py +++ b/arkdoc/generator/base.py @@ -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) diff --git a/arkdoc/generator/html.py b/arkdoc/generator/html.py index e504cc2..fae937b 100644 --- a/arkdoc/generator/html.py +++ b/arkdoc/generator/html.py @@ -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"Last generation at {datetime.now()}" @@ -111,7 +111,7 @@ 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 ] ), @@ -119,10 +119,11 @@ def generate_index(self): 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, @@ -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, diff --git a/templates/banner.html b/templates/banner.html index 0c60953..cc92044 100644 --- a/templates/banner.html +++ b/templates/banner.html @@ -7,7 +7,7 @@ @@ -60,8 +60,8 @@ - - + + \ No newline at end of file