예제 #1
0
def make_autodoc(make: bool, destroy_first: bool) -> None:
    if destroy_first:
        if make and os.path.exists(AUTODOC_DIR):
            log.info("Deleting directory {!r}", AUTODOC_DIR)
            rmtree(AUTODOC_DIR)
        else:
            log.warning("Would delete directory {!r} (not doing so as in mock "
                        "mode)", AUTODOC_DIR)
    top_idx = AutodocIndex(
        autodoc_rst_root_dir=AUTODOC_DIR,
        highest_code_dir=CODE_ROOT_DIR,
        index_filename=TOP_AUTODOC_INDEX,
        index_heading_underline_char="-",
        method=AutodocMethod.BEST,
        project_root_dir=PROJECT_ROOT_DIR,
        python_package_root_dir=PROJECT_ROOT_DIR,
        recursive=True,
        rst_prefix=COPYRIGHT_COMMENT,
        source_filenames_or_globs=[
            os.path.join(CODE_ROOT_DIR, "**/*.py"),
        ],
        source_rst_heading_underline_char="~",
        toctree_maxdepth=1,
    )
    top_idx.write_index_and_rst_files(overwrite=True, mock=not make)
예제 #2
0
def make_subindex(directory: str,
                  skip_globs: List[str] = None,
                  method: AutodocMethod = AutodocMethod.BEST) -> AutodocIndex:
    return AutodocIndex(
        index_filename=os.path.join(AUTODOC_DIR, directory, INDEX_FILENAME),
        project_root_dir=PROJECT_ROOT_DIR,
        python_package_root_dir=PYTHON_PACKAGE_ROOT_DIR,
        autodoc_rst_root_dir=AUTODOC_DIR,
        highest_code_dir=CODE_ROOT_DIR,
        source_filenames_or_globs=[
            os.path.join(CODE_ROOT_DIR, directory, "**/*.cpp"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.css"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.h"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.iss"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.java"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.pro"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.py"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.qml"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.rc"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.sci"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.xml"),
        ],
        rst_prefix=COPYRIGHT_COMMENT,
        title=directory,  # path style, not module style
        skip_globs=skip_globs,
        # source_rst_title_style_python=False,
        index_heading_underline_char="~",
        source_rst_heading_underline_char="^",
        method=method,
        pygments_language_override=PYGMENTS_OVERRIDE)
def make_autodoc(make: bool, destroy_first: bool) -> None:
    if destroy_first:
        if make and os.path.exists(AUTODOC_DIR):
            log.info("Deleting directory {!r}".format(AUTODOC_DIR))
            rmtree(AUTODOC_DIR)
        else:
            log.warning("Would delete directory {!r} (not doing so as in mock "
                        "mode)".format(AUTODOC_DIR))
    idx = AutodocIndex(
        index_filename=AUTODOC_INDEX,
        project_root_dir=PACKAGE_ROOT_DIR,
        autodoc_rst_root_dir=AUTODOC_DIR,
        highest_code_dir=CODE_ROOT_DIR,
        source_filenames_or_globs=[
            os.path.join(CODE_ROOT_DIR, "**/*.py"),
        ],
        skip_globs=["__init__.py", "env.py"],
    )
    idx.write_index_and_rst_files(overwrite=True, mock=not make)
예제 #4
0
def make_autodoc(make: bool, destroy_first: bool) -> None:
    if destroy_first:
        if make and os.path.exists(AUTODOC_DIR):
            log.info(f"Deleting directory {AUTODOC_DIR!r}")
            rmtree(AUTODOC_DIR)
        else:
            log.warning(f"Would delete directory {AUTODOC_DIR!r} "
                        f"(not doing so as in mock mode)")
    top_idx = AutodocIndex(
        index_filename=TOP_AUTODOC_INDEX,
        project_root_dir=PACKAGE_ROOT_DIR,
        autodoc_rst_root_dir=AUTODOC_DIR,
        highest_code_dir=CODE_ROOT_DIR,
        toctree_maxdepth=2,
        rst_prefix=COPYRIGHT_COMMENT,
    )
    top_idx.add_indexes([
        make_subindex("anonymise"),
        make_subindex("common"),
        make_subindex("crateweb"),
        make_subindex("nlp_manager"),
        make_subindex("nlp_webserver"),
        make_subindex("preprocess"),
        make_subindex("tools"),
    ])
    top_idx.write_index_and_rst_files(overwrite=True, mock=not make)
예제 #5
0
def make_subindex(directory: str) -> AutodocIndex:
    return AutodocIndex(
        index_filename=os.path.join(AUTODOC_DIR, directory, INDEX_FILENAME),
        project_root_dir=PACKAGE_ROOT_DIR,
        autodoc_rst_root_dir=AUTODOC_DIR,
        highest_code_dir=CODE_ROOT_DIR,
        source_filenames_or_globs=[
            os.path.join(CODE_ROOT_DIR, directory, "**/*.css"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.html"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.mako"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.py"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.java"),
            os.path.join(CODE_ROOT_DIR, directory, "**/*.js"),
        ],
        rst_prefix=COPYRIGHT_COMMENT,
        title="crate_anon/" + directory,  # path style, not module style
        skip_globs=SKIP_GLOBS,
        # source_rst_title_style_python=False,
    )
예제 #6
0
def make_autodoc(make: bool, destroy_first: bool) -> None:
    if destroy_first:
        if make and os.path.exists(AUTODOC_DIR):
            log.info("Deleting directory {!r}", AUTODOC_DIR)
            rmtree(AUTODOC_DIR)
        else:
            log.warning(
                "Would delete directory {!r} (not doing so as in mock "
                "mode)", AUTODOC_DIR)
    top_idx = AutodocIndex(index_filename=TOP_AUTODOC_INDEX,
                           project_root_dir=PROJECT_ROOT_DIR,
                           python_package_root_dir=PYTHON_PACKAGE_ROOT_DIR,
                           autodoc_rst_root_dir=AUTODOC_DIR,
                           highest_code_dir=CODE_ROOT_DIR,
                           toctree_maxdepth=1,
                           rst_prefix=COPYRIGHT_COMMENT,
                           index_heading_underline_char="-",
                           source_rst_heading_underline_char="~",
                           pygments_language_override=PYGMENTS_OVERRIDE)
    top_idx.add_indexes([
        make_subindex("tablet_qt", method=AutodocMethod.CONTENTS),
        make_subindex(os.path.join("server", "camcops_server")),
    ])
    top_idx.write_index_and_rst_files(overwrite=True, mock=not make)