Esempio n. 1
0
def generate(dest_dir):
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        'https://github.com/keras-team/keras-autodoc/blob/master',
    )
    doc_generator.generate(dest_dir)
    shutil.copyfile(keras_autodoc_dir / 'README.md', dest_dir / 'index.md')
Esempio n. 2
0
def generate(dest_dir):
    template_dir = project_dir / 'docs' / 'templates'
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES, 'https://github.com/datamllab/AutoRecSys', template_dir,
        project_dir / 'examples')
    doc_generator.generate(dest_dir)
    readme = (project_dir / 'README.md').read_text()
    index = (template_dir / 'index.md').read_text()
    index = index.replace('{{autogenerated}}', readme[readme.find('##'):])
    (dest_dir / 'index.md').write_text(index, encoding='utf-8')
Esempio n. 3
0
def generate(dest_dir):
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        project_url=
        "https://github.com/logicalclocks/feature-store-api/blob/master/python",
        template_dir="./docs/templates",
    )
    shutil.copyfile(hsfs_dir / "CONTRIBUTING.md", dest_dir / "contributing.md")
    shutil.copyfile(hsfs_dir / "README.md", dest_dir / "index.md")

    doc_generator.generate(dest_dir / "generated")
Esempio n. 4
0
def generate(dest_dir):
    template_dir = kerastuner_dir / 'docs' / 'templates'

    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES, 'https://github.com/keras-team/keras-tuner/blob/master',
        template_dir, kerastuner_dir / 'examples')
    doc_generator.generate(dest_dir)

    readme = (kerastuner_dir / 'README.md').read_text()
    index = (template_dir / 'index.md').read_text()
    index = index.replace('{{autogenerated}}', readme[readme.find('##'):])
    (dest_dir / 'index.md').write_text(index, encoding='utf-8')
    shutil.copyfile(kerastuner_dir / 'CONTRIBUTING.md',
                    dest_dir / 'contributing.md')
Esempio n. 5
0
def generate(dest_dir):
    template_dir = kerastuner_dir / "docs" / "templates"

    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        "https://github.com/keras-team/keras-tuner/blob/master",
        template_dir,
        kerastuner_dir / "examples",
    )
    doc_generator.generate(dest_dir)

    readme = (kerastuner_dir / "README.md").read_text()
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##") :])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")
    shutil.copyfile(kerastuner_dir / "CONTRIBUTING.md", dest_dir / "contributing.md")
    shutil.copyfile(kerastuner_dir / "docs" / "extra.css", dest_dir / "extra.css")
Esempio n. 6
0
def generate(dest_dir):
    api_dir = ai2business_dir / "docs" / "api"
    template_dir = ai2business_dir / "docs" / "templates"
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        "https://github.com/ai2business/ai2business/blob/main",
        api_dir,
        template_dir,
        # ai2business_dir / 'examples',
        extra_aliases=aliases_needed,
    )
    doc_generator.generate(dest_dir)
    readme = (ai2business_dir / "README.md").read_text()
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##") :])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")
    py_to_nb_md(dest_dir)
Esempio n. 7
0
def generate(dest_dir):
    template_dir = autokeras_dir / 'docs' / 'templates'
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        'https://github.com/keras-team/autokeras/blob/master',
        template_dir,
        autokeras_dir / 'examples',
        extra_aliases=aliases_needed,
    )
    doc_generator.generate(dest_dir)
    readme = (autokeras_dir / 'README.md').read_text()
    index = (template_dir / 'index.md').read_text()
    index = index.replace('{{autogenerated}}', readme[readme.find('##'):])
    (dest_dir / 'index.md').write_text(index, encoding='utf-8')
    shutil.copyfile(autokeras_dir / '.github' / 'CONTRIBUTING.md',
                    dest_dir / 'contributing.md')

    py_to_nb_md(dest_dir)
Esempio n. 8
0
def generate(dest_dir):
    template_dir = autokeras_dir / "docs" / "templates"
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        "https://github.com/keras-team/autokeras/blob/master",
        template_dir,
        autokeras_dir / "examples",
        extra_aliases=aliases_needed,
    )
    doc_generator.generate(dest_dir)
    readme = (autokeras_dir / "README.md").read_text()
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##"):])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")
    shutil.copyfile(autokeras_dir / ".github" / "CONTRIBUTING.md",
                    dest_dir / "contributing.md")

    py_to_nb_md(dest_dir)
Esempio n. 9
0
def generate(dest_dir):
    doc_generator = keras_autodoc.DocumentationGenerator(
        PAGES,
        project_url="https://github.com/logicalclocks/feature-store-api/blob/master/python",
        template_dir="./docs/templates",
        titles_size="###",
        extra_aliases={
            "hsfs.core.query.Query": "hsfs.Query",
            "hsfs.storage_connector.StorageConnector": "hsfs.StorageConnector",
            "hsfs.statistics_config.StatisticsConfig": "hsfs.StatisticsConfig",
            "hsfs.training_dataset_feature.TrainingDatasetFeature": "hsfs.TrainingDatasetFeature",
            "pandas.core.frame.DataFrame": "pandas.DataFrame",
        },
        max_signature_line_length=100,
    )
    shutil.copyfile(hsfs_dir / "CONTRIBUTING.md", dest_dir / "CONTRIBUTING.md")
    shutil.copyfile(hsfs_dir / "README.md", dest_dir / "index.md")

    doc_generator.generate(dest_dir / "generated")
Esempio n. 10
0
def generate(dest_dir: Path):
    template_dir = icevision_dir / "docs" / "templates"
    template_images_dir = Path(template_dir) / "images"

    # Create dest_dir if doesn't exist
    if os.path.exists(dest_dir):
        print("Removing sources folder:", dest_dir)
        shutil.rmtree(dest_dir)
    os.makedirs(dest_dir)

    # Copy images folder from root folder to the template images folder
    copy_tree(str(icevision_dir / "images"), str(template_images_dir))

    # Generate APIs Documentation
    doc_generator = keras_autodoc.DocumentationGenerator(
        pages=PAGES,
        project_url="https://github.com/airctic/icevision/blob/master",
        template_dir=template_dir,
        examples_dir=icevision_dir / "examples",
    )
    doc_generator.generate(dest_dir)

    # Copy CNAME file
    shutil.copyfile(icevision_dir / "CNAME", dest_dir / "CNAME")

    # Copy web manifest
    shutil.copyfile("manifest.webmanifest", dest_dir / "manifest.webmanifest")

    # Auto generate the index.md file using the README.md file and the index.md file in templates folder
    readme = (icevision_dir / "README.md").read_text()

    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    start = readme.find("<!-- Not included in docs - start -->")
    end = readme.find("<!-- Not included in docs - end -->")
    print("\nSTART: ", start)
    print("END: ", end, "\n")
    readme = readme.replace(readme[start:end], "")
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##") :])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")

    # Copy static .md files from the root folder
    shutil.copyfile(icevision_dir / "CONTRIBUTING.md", dest_dir / "contributing.md")
    shutil.copyfile(
        icevision_dir / "CODE_OF_CONDUCT.md", dest_dir / "code_of_conduct.md"
    )

    # Copy static .md files from the docs folder
    shutil.copyfile(icevision_dir / "docs/INSTALL.md", dest_dir / "install.md")
    shutil.copyfile(
        icevision_dir / "docs/HOW-TO.md",
        dest_dir / "how-to.md",
    )
    shutil.copyfile(icevision_dir / "docs/ABOUT.md", dest_dir / "about.md")

    shutil.copyfile(icevision_dir / "docs/README.md", dest_dir / "readme_mkdocs.md")

    shutil.copyfile(
        icevision_dir / "docs/CHANGING-THE-COLORS.md",
        dest_dir / "changing_the_colors.md",
    )

    shutil.copyfile(icevision_dir / "docs/DEPLOYMENT.md", dest_dir / "deployment.md")

    # Copy static .md files from the other folders
    shutil.copyfile(
        icevision_dir / "icevision/models/README.md",
        dest_dir / "model_comparison.md",
    )

    shutil.copyfile(
        icevision_dir / "icevision/models/ross/efficientdet/README.md",
        dest_dir / "model_efficientdet.md",
    )

    shutil.copyfile(
        icevision_dir / "icevision/models/torchvision/faster_rcnn/README.md",
        dest_dir / "model_faster_rcnn.md",
    )

    shutil.copyfile(
        icevision_dir / "icevision/backbones/backbones_effecientdet.md",
        dest_dir / "backbones_effecientdet.md",
    )

    shutil.copyfile(
        icevision_dir / "icevision/backbones/backbones_faster_mask_rcnn.md",
        dest_dir / "backbones_faster_mask_rcnn.md",
    )

    shutil.copyfile(
        icevision_dir / "icevision/tfms/README.md",
        dest_dir / "albumentations.md",
    )

    # Copy .md examples files to destination examples folder
    # Copy css folder
    copy_tree(str(icevision_dir / "examples"), str(dest_dir / "examples"))

    # Copy images folder from the template folder to the destination folder
    print("Template folder: ", template_images_dir)
    dest_images_dir = Path(dest_dir) / "images"

    # Copy images folder
    copy_tree(str(template_images_dir), str(dest_images_dir))

    # Copy css folder
    copy_tree(str(icevision_dir / "docs/css"), str(dest_dir / "css"))

    # Copy js folder
    copy_tree(str(icevision_dir / "docs/js"), str(dest_dir / "js"))

    # Generate .md files form Jupyter Notebooks located in the /notebooks folder
    nb_to_md(icevision_dir, "notebooks", dest_dir)

    # Generate .md files form Jupyter Notebooks located in the /deployment folder
    nb_to_md(icevision_dir / "docs", "deployment", dest_dir)
Esempio n. 11
0
def generate(dest_dir: Path):
    template_dir = icevision_dir / "docs" / "templates"
    template_images_dir = Path(template_dir) / "images"

    # Create dest_dir if doesn't exist
    if os.path.exists(dest_dir):
        print("Removing sources folder:", dest_dir)
        logger.opt(colors=True).log(
            "INFO",
            "️<magenta><bold>\nRemoving sources folder: {}</></>",
            dest_dir,
        )
        shutil.rmtree(dest_dir)
    os.makedirs(dest_dir)

    # Copy images folder from root folder to the template images folder
    copy_tree(str(icevision_dir / "images"), str(template_images_dir))
    from_to = f"root/images -> docs/images"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying images folder: {}</></>",
        from_to,
    )

    # Generate APIs Documentation
    doc_generator = keras_autodoc.DocumentationGenerator(
        pages=PAGES,
        project_url="https://github.com/airctic/icedata/blob/master",
        template_dir=template_dir,
        examples_dir=icevision_dir / "examples",
    )
    doc_generator.generate(dest_dir)

    # Copy CNAME file
    shutil.copyfile(icevision_dir / "CNAME", dest_dir / "CNAME")

    # Copy web manifest
    shutil.copyfile("manifest.webmanifest", dest_dir / "manifest.webmanifest")
    from_to = f"root/manifest.webmanifest -> docs/manifest.webmanifest"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying webmanifest file: {}</></>",
        from_to,
    )

    # Auto generate the index.md file using the README.md file and the index.md file in templates folder
    readme = (icevision_dir / "README.md").read_text()

    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    start = readme.find("<!-- Not included in docs - start -->")
    end = readme.find("<!-- Not included in docs - end -->")

    readme = readme.replace(readme[start:end], "")
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##"):])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")

    # Copy static .md files from the root folder
    dir_to_search = icevision_dir
    fnamelist = [
        filename for filename in os.listdir(dir_to_search)
        if filename.endswith(".md")
    ]
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying .md files root folder: {}</></>",
        fnamelist,
    )

    for fname in fnamelist:
        fname_src = icevision_dir / fname
        fname_dst = dest_dir / fname.lower()
        shutil.copyfile(fname_src, fname_dst)
        from_to = f"{fname} -> {fname.lower()}"
        logger.opt(colors=True).log(
            "INFO",
            "️<light-blue><bold>file: {}</></>",
            from_to,
        )

    # Copy static .md files from the docs folder
    dir_to_search = icevision_dir / "docs"
    fnamelist = [
        filename for filename in os.listdir(dir_to_search)
        if filename.endswith(".md")
    ]
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying .md files from the docs folder: {}</></>",
        fnamelist,
    )
    for fname in fnamelist:
        fname_src = dir_to_search / fname
        fname_dst = dest_dir / fname.lower()
        shutil.copyfile(fname_src, fname_dst)
        from_to = f"{fname} -> {fname.lower()}"
        logger.opt(colors=True).log(
            "INFO",
            "️<light-blue><bold>Copying files: {}</></>",
            from_to,
        )

    # Copy images folder from the template folder to the destination folder
    # print("Template folder: ", template_images_dir)
    dest_images_dir = Path(dest_dir) / "images"

    # Copy images folder
    copy_tree(str(template_images_dir), str(dest_images_dir))
    from_to = f"{template_images_dir} -> {dest_images_dir}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying Images: {}</></>",
        from_to,
    )

    # Copy css folder
    css_dir_src = str(icevision_dir / "docs/css")
    css_dir_dest = str(str(dest_dir / "css"))
    copy_tree(css_dir_src, css_dir_dest)
    from_to = f"{css_dir_src} -> {css_dir_dest}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying CSS files: {}</></>",
        from_to,
    )

    # Copy js folder
    # copy_tree(str(icevision_dir / "docs/js"), str(dest_dir / "js"))
    js_dir_src = str(icevision_dir / "docs/js")
    js_dir_dest = str(str(dest_dir / "js"))
    copy_tree(js_dir_src, js_dir_dest)
    from_to = f"{js_dir_src} -> {js_dir_dest}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying JS files: {}</></>",
        from_to,
    )

    # Generate .md files form Jupyter Notebooks located in the /notebooks folder
    nb_to_md(icevision_dir, "notebooks", dest_dir)

    # Generate .md files form Jupyter Notebooks located in the /deployment folder
    nb_to_md(icevision_dir / "docs", "deployment", dest_dir)

    # albumentations
    shutil.copyfile(
        icevision_dir / "icevision/tfms/README.md",
        dest_dir / "albumentations.md",
    )

    # Models
    shutil.copyfile(
        icevision_dir / "icevision/models/README.md",
        dest_dir / "models.md",
    )

    # Backbones
    shutil.copyfile(
        icevision_dir / "icevision/backbones/README.md",
        dest_dir / "backbones.md",
    )
Esempio n. 12
0
def generate(dest_dir: Path):
    template_dir = icedata_dir / "docs" / "templates"
    template_images_dir = Path(template_dir) / "images"
    datasets_dir = dest_dir / "datasets"

    # Create dest_dir if doesn't exist
    if os.path.exists(dest_dir):
        print("Removing sources folder:", dest_dir)
        shutil.rmtree(dest_dir)
    os.makedirs(dest_dir)

    # Create datasets_dir
    print("datasets_dir folder:", datasets_dir)
    os.makedirs(datasets_dir)

    # Copy images folder from root folder to the template images folder
    copy_tree(str(icedata_dir / "images"), str(template_images_dir))

    # Generate APIs Documentation
    doc_generator = keras_autodoc.DocumentationGenerator(
        pages=PAGES,
        project_url="https://github.com/airctic/icedata/blob/master",
        template_dir=template_dir,
        examples_dir=icedata_dir / "examples",
    )
    doc_generator.generate(dest_dir)

    # Copy CNAME file
    # shutil.copyfile(icedata_dir / "CNAME", dest_dir / "CNAME")

    # Copy web manifest
    shutil.copyfile("manifest.webmanifest", dest_dir / "manifest.webmanifest")

    # Auto generate the index.md file using the README.md file and the index.md file in templates folder
    readme = (icedata_dir / "README.md").read_text()

    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    start = readme.find("<!-- Not included in docs - start -->")
    end = readme.find("<!-- Not included in docs - end -->")
    print("\nSTART: ", start)
    print("END: ", end, "\n")
    readme = readme.replace(readme[start:end], "")
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##") :])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")

    # Copy static .md files from the root folder
    shutil.copyfile(icedata_dir / "CONTRIBUTING.md", dest_dir / "contributing.md")
    shutil.copyfile(icedata_dir / "CODE_OF_CONDUCT.md", dest_dir / "code_of_conduct.md")
    shutil.copyfile(
        icedata_dir / "PARSING_CHEATSHEET.md", dest_dir / "parsing_cheatsheet.md"
    )
    shutil.copyfile(icedata_dir / "DATASETS_TOOLS.md", dest_dir / "datasets_tools.md")

    # Copy static .md files from the docs folder
    shutil.copyfile(icedata_dir / "docs/INSTALL.md", dest_dir / "install.md")
    shutil.copyfile(icedata_dir / "docs/HOW-TO.md", dest_dir / "how-to.md")
    shutil.copyfile(icedata_dir / "docs/ABOUT.md", dest_dir / "about.md")

    shutil.copyfile(icedata_dir / "docs/README.md", dest_dir / "readme_mkdocs.md")

    shutil.copyfile(
        icedata_dir / "docs/CHANGING-THE-COLORS.md",
        dest_dir / "changing_the_colors.md",
    )

    # Copy Birds README
    shutil.copyfile(
        icedata_dir / "icedata/datasets/birds/README.md", dest_dir / "birds.md"
    )

    # Copy COCO README
    shutil.copyfile(
        icedata_dir / "icedata/datasets/coco/README.md", dest_dir / "coco.md"
    )

    # Copy PETS README
    shutil.copyfile(icedata_dir / "icedata/datasets/voc/README.md", dest_dir / "voc.md")

    # Copy PETS README
    shutil.copyfile(
        icedata_dir / "icedata/datasets/pets/README.md", dest_dir / "pets.md"
    )

    # Copy Fridge README
    shutil.copyfile(
        icedata_dir / "icedata/datasets/fridge/README.md", dest_dir / "fridge.md"
    )

    # Copy PennFudan README
    shutil.copyfile(
        icedata_dir / "icedata/datasets/pennfudan/README.md", dest_dir / "pennfudan.md"
    )

    # Copy .md examples files to destination examples folder
    copy_tree(str(icedata_dir / "examples"), str(dest_dir / "examples"))

    # Copy images folder from the template folder to the destination folder
    print("Template folder: ", template_images_dir)
    dest_images_dir = Path(dest_dir) / "images"

    # Copy images folder
    copy_tree(str(template_images_dir), str(dest_images_dir))

    # Copy css folder
    copy_tree(str(icedata_dir / "docs/css"), str(dest_dir / "css"))

    # Copy js folder
    copy_tree(str(icedata_dir / "docs/js"), str(dest_dir / "js"))

    # Generate .md files form Jupyter Notebooks located in the /ipynb folder
    nb_to_md(dest_dir)
Esempio n. 13
0
def generate(dest_dir: Path):
    template_dir = icedata_dir / "docs" / "templates"
    template_images_dir = Path(template_dir) / "images"
    datasets_dir = dest_dir / "datasets"

    # Create dest_dir if doesn't exist
    if os.path.exists(dest_dir):
        print("Removing sources folder:", dest_dir)
        logger.opt(colors=True).log(
            "INFO",
            "️<magenta><bold>\nRemoving sources folder: {}</></>",
            dest_dir,
        )
        shutil.rmtree(dest_dir)
    os.makedirs(dest_dir)

    # Create datasets_dir
    os.makedirs(datasets_dir)
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCreating datasets folder: {}</></>",
        datasets_dir,
    )

    # Copy images folder from root folder to the template images folder
    copy_tree(str(icedata_dir / "images"), str(template_images_dir))
    from_to = f"root/images -> docs/images"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying images folder: {}</></>",
        from_to,
    )

    # Generate APIs Documentation
    doc_generator = keras_autodoc.DocumentationGenerator(
        pages=PAGES,
        project_url="https://github.com/airctic/icedata/blob/master",
        template_dir=template_dir,
    )
    doc_generator.generate(dest_dir)

    # Copy CNAME file
    # shutil.copyfile(icedata_dir / "CNAME", dest_dir / "CNAME")

    # Copy web manifest
    shutil.copyfile("manifest.webmanifest", dest_dir / "manifest.webmanifest")
    from_to = f"root/manifest.webmanifest -> docs/manifest.webmanifest"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying webmanifest file: {}</></>",
        from_to,
    )

    # Auto generate the index.md file using the README.md file and the index.md file in templates folder
    readme = (icedata_dir / "README.md").read_text()

    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    start = readme.find("<!-- Not included in docs - start -->")
    end = readme.find("<!-- Not included in docs - end -->")

    readme = readme.replace(readme[start:end], "")
    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##") :])
    (dest_dir / "index.md").write_text(index, encoding="utf-8")

    # Copy static .md files from the root folder
    dir_to_search = icedata_dir
    fnamelist = [
        filename for filename in os.listdir(dir_to_search) if filename.endswith(".md")
    ]
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying .md files root folder: {}</></>",
        fnamelist,
    )

    for fname in fnamelist:
        fname_src = icedata_dir / fname
        fname_dst = dest_dir / fname.lower()
        shutil.copyfile(fname_src, fname_dst)
        from_to = f"{fname} -> {fname.lower()}"
        logger.opt(colors=True).log(
            "INFO",
            "️<light-blue><bold>file: {}</></>",
            from_to,
        )

    # Copy static .md files from the docs folder
    dir_to_search = icedata_dir / "docs"
    fnamelist = [
        filename for filename in os.listdir(dir_to_search) if filename.endswith(".md")
    ]
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nCopying .md files from the docs folder: {}</></>",
        fnamelist,
    )
    for fname in fnamelist:
        fname_src = dir_to_search / fname
        fname_dst = dest_dir / fname.lower()
        shutil.copyfile(fname_src, fname_dst)
        from_to = f"{fname} -> {fname.lower()}"
        logger.opt(colors=True).log(
            "INFO",
            "️<light-blue><bold>Copying files: {}</></>",
            from_to,
        )

    # shutil.copyfile(icedata_dir / "docs/INSTALL.md", dest_dir / "install.md")
    # shutil.copyfile(icedata_dir / "docs/HOW-TO.md", dest_dir / "how-to.md")
    # shutil.copyfile(icedata_dir / "docs/ABOUT.md", dest_dir / "about.md")

    # shutil.copyfile(icedata_dir / "docs/README.md", dest_dir / "readme_mkdocs.md")

    # shutil.copyfile(
    #     icedata_dir / "docs/CHANGING-THE-COLORS.md",
    #     dest_dir / "changing_the_colors.md",
    # )

    ## Add each dataset README
    dir_to_search = icedata_dir / "icedata/datasets"
    ds_dirlist = sorted(
        [
            filename
            for filename in os.listdir(dir_to_search)
            if (
                os.path.isdir(os.path.join(dir_to_search, filename))
                and not filename.startswith("_")
            )
        ]
    )

    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>\nList of datasets: {}</></>",
        ds_dirlist,
    )

    for i, directory in enumerate(ds_dirlist):
        fname_src = f"icedata/datasets/{directory}/README.md"
        fname_dst = f"{directory}.md"
        from_to = f"{fname_src} -> {fname_dst}"
        shutil.copyfile(icedata_dir / fname_src, dest_dir / fname_dst)
        logger.opt(colors=True).log(
            "INFO",
            "️<light-blue><bold>Copying files: : {}</></>",
            from_to,
        )

    # Copy images folder from the template folder to the destination folder
    # print("Template folder: ", template_images_dir)
    dest_images_dir = Path(dest_dir) / "images"

    # Copy images folder
    copy_tree(str(template_images_dir), str(dest_images_dir))
    from_to = f"{template_images_dir} -> {dest_images_dir}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying Images: {}</></>",
        from_to,
    )

    # Copy css folder
    css_dir_src = str(icedata_dir / "docs/css")
    css_dir_dest = str(str(dest_dir / "css"))
    copy_tree(css_dir_src, css_dir_dest)
    from_to = f"{css_dir_src} -> {css_dir_dest}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying CSS files: {}</></>",
        from_to,
    )

    # Copy js folder
    # copy_tree(str(icedata_dir / "docs/js"), str(dest_dir / "js"))
    js_dir_src = str(icedata_dir / "docs/js")
    js_dir_dest = str(str(dest_dir / "js"))
    copy_tree(js_dir_src, js_dir_dest)
    from_to = f"{js_dir_src} -> {js_dir_dest}"
    logger.opt(colors=True).log(
        "INFO",
        "️<green><bold>Copying JS files: {}</></>",
        from_to,
    )

    # Generate .md files form Jupyter Notebooks located in the /ipynb folder
    nb_to_md(dest_dir)

    ## generate - Datasets Navigation Items
    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    mkdocs_yml = (icedata_dir / "docs/mkdocs.yml").read_text()
    start = mkdocs_yml.find("- Datasets")
    end = mkdocs_yml.find("  - API Documentation")

    ds_nav = "- Datasets:\n"
    for directory in ds_dirlist:
        ds_nav = (
            ds_nav + f"    - {directory[:1].upper() + directory[1:]}: {directory}.md\n"
        )
    ds_nav + "\n"

    mkdocs_yml = mkdocs_yml.replace(mkdocs_yml[start:end], ds_nav)
    (icedata_dir / "docs/mkdocs.yml").write_text(mkdocs_yml, encoding="utf-8")

    logger.opt(colors=True).log(
        "INFO",
        "️<fg #FFC000><bold>\nCreating datasets navigation bar: \n{}</></>",
        ds_nav,
    )
Esempio n. 14
0
def generate(dest_dir):
    template_dir = picturate_dir / "docs" / "templates"

    # Create dest_dir if doesn't exist
    if os.path.exists(dest_dir):
        print("Removing sources folder:", dest_dir)
        shutil.rmtree(dest_dir)

    os.makedirs(dest_dir)

    doc_generator = keras_autodoc.DocumentationGenerator(
        pages=PAGES,
        project_url="https://github.com/picturate/picturate/blob/master",
        template_dir=template_dir,
        examples_dir=picturate_dir / "examples",
    )
    doc_generator.generate(dest_dir)

    # Auto generate the index.md file using the README.md file and the index.md file in templates folder
    readme = (picturate_dir / "README.md").read_text()

    # Search for the beginning and the end of the installation procedure to hide in Docs to avoid duplication
    start = readme.find("<!-- Not included in docs - start -->")
    end = readme.find("<!-- Not included in docs - end -->")
    print("\nSTART: ", start)
    print("END: ", end, "\n")
    readme = readme.replace(readme[start:end], "")

    index = (template_dir / "index.md").read_text()
    index = index.replace("{{autogenerated}}", readme[readme.find("##"):])

    (dest_dir / "index.md").write_text(index, encoding="utf-8")

    # Copy static .md files from the root folder
    # shutil.copyfile(picturate_dir / "ABOUT.md", dest_dir / "about.md")
    # shutil.copyfile(picturate_dir / "CONTRIBUTING.md", dest_dir / "contributing.md")
    # shutil.copyfile(picturate_dir / "DOCKER.md", dest_dir / "docker.md")
    # shutil.copyfile(picturate_dir / "INSTALL.md", dest_dir / "install.md")
    # shutil.copyfile(
    #     picturate_dir / "README_MKDOCS.md", dest_dir / "readme_mkdocs.md"
    # )
    # shutil.copyfile(
    #     picturate_dir / "CHANGING-THE-COLORS.md", dest_dir / "changing-the-colors.md"
    # )
    # shutil.copyfile(picturate_dir / "DEPLOYMENT.md", dest_dir / "deployment.md")
    # shutil.copyfile(picturate_dir / "MODEL_FASTER_RCNN.md", dest_dir / "model_faster_rcnn.md")

    # Copy images folder from the template folder to the destination folder
    template_images_dir = Path(template_dir) / "images"
    print("Template folder: ", template_images_dir)
    dest_images_dir = Path(dest_dir) / "images"

    if not os.path.exists(dest_images_dir):
        os.makedirs(dest_images_dir)

    if os.path.exists(template_images_dir):
        for fname in os.listdir(template_images_dir):
            src = Path(template_images_dir) / fname
            target = Path(dest_images_dir) / fname
            print("copy", src, "to", target)
            shutil.copyfile(src, target)

    # Generate .md files form Jupyter Notebooks located in the /ipynb folder
    nb_to_md(dest_dir)

    # Generate .md files form python files located in the /examples folder
    examples_to_md(dest_dir)