Skip to content

Commit

Permalink
Fix generation
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed Feb 17, 2024
1 parent 84a284b commit 15e2722
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/docs/api_reference_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def write(self) -> None:


class Package:
def __init__(self, path: pathlib.Path, header_override: t.Optional[str] = None) -> None:
def __init__(self, path: pathlib.Path, header_override: t.Optional[str] = None, child_prefix: t.Optional[str] = None) -> None:
self.path = path
self.header_override = header_override
self.child_prefix = [child_prefix] if child_prefix else []

self.packages = []
self.modules = []
Expand Down Expand Up @@ -83,11 +84,11 @@ def write(self) -> None:
package_name = self.header_override or ".".join(parts)

package_lines = [
f" {API_REFERENCES_DIRECTORY[-1]}/{'/'.join([*parts, package.path.name])}"
f" {'/'.join([*self.child_prefix, self.path.name, *package.path.relative_to(self.path).parts])}"
for package in self.packages
]
module_lines = [
f" {API_REFERENCES_DIRECTORY[-1]}/{'/'.join([*parts, module.path.name[:-3]])}"
f" {'/'.join([*self.child_prefix, self.path.name, *module.path.relative_to(self.path).parts])}"[:-3]
for module in self.modules
]

Expand All @@ -111,7 +112,7 @@ def is_package(path: pathlib.Path) -> bool:


def run() -> None:
Package(pathlib.Path("lightbulb"), header_override="API Reference").write()
Package(pathlib.Path("lightbulb"), header_override="API Reference", child_prefix=API_REFERENCES_DIRECTORY[-1]).write()
os.rename(
os.path.join(*API_REFERENCES_DIRECTORY, "lightbulb.rst"),
os.path.join(*API_REFERENCES_DIRECTORY[:-1], "api-reference.rst"),
Expand Down

0 comments on commit 15e2722

Please sign in to comment.