diff --git a/docs/source/conf.py b/docs/source/conf.py index d63523ab0..e16179cb0 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 @@ -79,6 +80,7 @@ extensions.append('util.cmdref') # 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 4deda41dd..63e6dd543 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 @@ class YosysCellDocumenter(Documenter): # 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 @@ class YosysCellSourceDocumenter(YosysCellDocumenter): 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)