Docs: Add cells loc config value

This commit is contained in:
Krystine Sherwin 2024-05-20 15:50:28 +12:00
parent 1b0d8633c4
commit ccd3bace23
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -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:

View File

@ -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)