diff --git a/docs/generate_implicitron_stubs.py b/docs/generate_implicitron_stubs.py index 43a9516a..2a2e54dd 100755 --- a/docs/generate_implicitron_stubs.py +++ b/docs/generate_implicitron_stubs.py @@ -19,7 +19,11 @@ def paths_to_modules(paths): """ Given an iterable of paths, return equivalent list of modules. """ - return [str(i.relative_to(ROOT_DIR))[:-3].replace("/", ".") for i in paths] + return [ + str(i.relative_to(ROOT_DIR))[:-3].replace("/", ".") + for i in paths + if "__pycache__" not in str(i) + ] def create_one_file(title, description, sources, dest_file): @@ -57,11 +61,17 @@ def iterate_directory(directory_path, dest): continue if subdir.name == "fb": continue + if subdir.name.startswith("_"): + continue iterate_directory(subdir, dest / (subdir.name)) toc.append(f"{subdir.name}/index") + paths_to_modules_ = paths_to_modules([directory_path.with_suffix(".XX")]) + if len(paths_to_modules_) == 0: + return + title = paths_to_modules_[0] + with open(dest / "index.rst", "w") as f: - title = paths_to_modules([directory_path.with_suffix(".XX")])[0] print(title, file=f) print("=" * len(title), file=f) print("\n.. toctree::\n", file=f) @@ -69,6 +79,22 @@ def iterate_directory(directory_path, dest): print(f" {item}", file=f) +def make_directory_index(title: str, directory_path: Path): + index_file = directory_path / "index.rst" + directory_rsts = sorted(directory_path.glob("*.rst")) + subdirs = sorted([f for f in directory_path.iterdir() if f.is_dir()]) + with open(index_file, "w") as f: + print(title, file=f) + print("=" * len(title), file=f) + print("\n.. toctree::\n", file=f) + for subdir in subdirs: + print(f" {subdir.stem}/index.rst", file=f) + for rst in directory_rsts: + if rst.stem == "index": + continue + print(f" {rst.stem}", file=f) + + iterate_directory(ROOT_DIR / "pytorch3d/implicitron/models", DEST_DIR / "models") unwanted_tools = ["configurable", "depth_cleanup", "utils"] @@ -118,3 +144,5 @@ create_one_file( paths_to_modules(evaluation_files), DEST_DIR / "evaluation.rst", ) + +make_directory_index("pytorch3d.implicitron", DEST_DIR) diff --git a/docs/modules/implicitron/index.rst b/docs/modules/implicitron/index.rst new file mode 100644 index 00000000..1fc4fa86 --- /dev/null +++ b/docs/modules/implicitron/index.rst @@ -0,0 +1,10 @@ +pytorch3d.implicitron +===================== + +.. toctree:: + + models/index.rst + data_basics + datasets + evaluation + tools diff --git a/docs/modules/implicitron/models/implicit_function/index.rst b/docs/modules/implicitron/models/implicit_function/index.rst index 60fdcd7a..343c377b 100644 --- a/docs/modules/implicitron/models/implicit_function/index.rst +++ b/docs/modules/implicitron/models/implicit_function/index.rst @@ -4,10 +4,10 @@ pytorch3d.implicitron.models.implicit_function .. toctree:: base - decoding_functions idr_feature_field neural_radiance_field scene_representation_networks utils + decoding_functions voxel_grid voxel_grid_implicit_function