From 2f53e7b8744e2f9a373c3a6cdde3d2162d00ad5a Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 May 2024 15:50:28 +1200 Subject: [PATCH] Docs: Add cells loc config value --- docs/source/conf.py | 2 ++ docs/util/cellref.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8af76ba806f..d9c4ae6d315 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from pathlib import Path import sys import os @@ -49,6 +50,7 @@ # use autodocs extensions.append('sphinx.ext.autodoc') extensions.append('util.cellref') +cells_loc = Path(__file__).parent / 'generated' from sphinx.application import Sphinx def setup(app: Sphinx) -> None: diff --git a/docs/util/cellref.py b/docs/util/cellref.py index 4deda41dddb..63e6dd543d7 100644 --- a/docs/util/cellref.py +++ b/docs/util/cellref.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from __future__ import annotations -from pathlib import Path +from pathlib import Path, PosixPath, WindowsPath import re from typing import Any @@ -140,7 +140,8 @@ def import_object(self, raiseerror: bool = False) -> bool: # find cell lib file objpath = Path('/'.join(self.objpath)) if not objpath.exists(): - objpath = Path('source') / 'generated' / objpath + cells_loc: Path = self.config.cells_loc + objpath = cells_loc / objpath # load cell lib try: @@ -358,6 +359,7 @@ def get_object_members( return False, [] def setup(app: Sphinx) -> dict[str, Any]: + app.add_config_value('cells_loc', False, 'html', [Path, PosixPath, WindowsPath]) app.setup_extension('sphinx.ext.autodoc') app.add_autodocumenter(YosysCellDocumenter) app.add_autodocumenter(YosysCellSourceDocumenter)