diff --git a/nb_autodoc/__main__.py b/nb_autodoc/__main__.py index ad678b3..d1e32e6 100644 --- a/nb_autodoc/__main__.py +++ b/nb_autodoc/__main__.py @@ -1,22 +1,50 @@ from typing import Tuple +from typing_extensions import Literal import click +from nb_autodoc.builders.markdown import MarkdownBuilder +from nb_autodoc.config import Config from nb_autodoc.log import logger +from nb_autodoc.manager import ModuleManager logger.setLevel("INFO") @click.command() -@click.argument("modules", nargs=-1, required=True) +@click.argument("module", required=True) @click.option( "-o", "--output-dir", default="build", type=click.Path(exists=False, file_okay=False, writable=True, executable=True), + show_default=True, ) -def main(modules: Tuple[str, ...], output_dir: str) -> None: - print(modules) +@click.option("-s", "--skip", multiple=True, help="skip import modules") +@click.option("-u", "--undoc", multiple=True, help="undocument modules") +@click.option( + "--markdown-linkmode", + default="heading_id", + type=click.Choice(["heading_id", "vuepress"]), + show_default=True, +) +def main( + module: str, + output_dir: str, + skip: Tuple[str, ...], + undoc: Tuple[str, ...], + markdown_linkmode: Literal["heading_id", "vuepress"], +) -> None: + manager = ModuleManager( + module, + config=Config( + output_dir=output_dir, + skip_import_modules=set(skip), + exclude_documentation_modules=set(undoc), + ), + ) + builder = MarkdownBuilder(manager, link_mode=markdown_linkmode) + builder.write() if __name__ == "__main__": diff --git a/nb_autodoc/config.py b/nb_autodoc/config.py index 8f71e3d..9b1517c 100644 --- a/nb_autodoc/config.py +++ b/nb_autodoc/config.py @@ -26,8 +26,11 @@ class Config(TypedDict, total=False): Carefully add this option on a dependent module because we want to analyze python object relationship. - Support `fnmatch` pattern, such as '*', '?', etc. + + Default: `frozenset()` + + CLI Flags: `-s`, `--skip` """ ### Builder Config ### @@ -46,10 +49,19 @@ class Config(TypedDict, total=False): """Exclude documentation modules. Support `fnmatch` pattern, such as '*', '?', etc. + + Default: `frozenset()` + + CLI Flags: `-u`, `--undoc` """ output_dir: str - """Documentation output directory. Default to 'build'.""" + """Documentation output directory. + + Default: `'build'`. + + CLI Flags: `-o`, `--output-dir` + """ write_encoding: str """File encoding to write. Default to 'utf-8'."""