From ccd3bace2303ee0a33ce2e04dcb362497e9b9c14 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 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)