|
15 | 15 |
|
16 | 16 | import sys |
17 | 17 | import os |
| 18 | +import importlib |
18 | 19 |
|
19 | 20 | # If extensions (or modules to document with autodoc) are in another directory, |
20 | 21 | # add these directories to sys.path here. If the directory is relative to the |
21 | 22 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
22 | 23 | #sys.path.insert(0, os.path.abspath('.')) |
23 | 24 | rootdir = os.environ.get('ROOTDIR') |
24 | | -sys.path.append(rootdir + 'python-scripts') |
| 25 | +sys.path.insert(0, os.path.abspath(rootdir)) |
| 26 | + |
| 27 | +from scripts import interpretvalues, sectinc, replacevars |
25 | 28 |
|
26 | 29 | # -- General configuration ------------------------------------------------ |
27 | 30 |
|
|
42 | 45 | ] |
43 | 46 |
|
44 | 47 | # Add any paths that contain templates here, relative to this directory. |
45 | | -templates_path = ['../_templates'] |
| 48 | +templates_path = ['_templates'] |
46 | 49 |
|
47 | 50 | # The suffix(es) of source filenames. |
48 | 51 | # You can specify multiple suffix as a list of string: |
|
240 | 243 |
|
241 | 244 | # Suppress warnings about excluded documents because every device gets a different toc tree |
242 | 245 | suppress_warnings = ['toc.excluded'] |
| 246 | + |
| 247 | +# -- Tag file loader ------------------------------------------------------ |
| 248 | + |
| 249 | +# Defaults |
| 250 | +exclude_patterns = [] |
| 251 | + |
| 252 | +FAMILY = os.environ.get("DEVFAMILY", "") |
| 253 | +OS = os.environ.get("OS", "") |
| 254 | +try: |
| 255 | + globals().update(importlib.import_module(f"configs.{FAMILY}.{FAMILY}_{OS}_tags").__dict__) |
| 256 | +except ModuleNotFoundError as exc: |
| 257 | + raise ModuleNotFoundError("Configuration not supported!") from exc |
| 258 | + |
| 259 | +# -- Family setup --------------------------------------------------------- |
| 260 | + |
| 261 | +# List of Inclusion TOC files to use |
| 262 | +family_tocfiles = [f"{FAMILY}/{FAMILY}_{OS}_toc.txt"] |
| 263 | +# Family Configuration file to use |
| 264 | +family_config_inputfile = f"{FAMILY}/{FAMILY}_{OS}_config.txt" |
| 265 | + |
| 266 | +# Hash table for Replacement Variables |
| 267 | +family_replacevars = {} |
| 268 | +# Hash table for Configuration Values |
| 269 | +family_configvals = {} |
| 270 | + |
| 271 | +def setup(app): |
| 272 | + """ |
| 273 | + Sphinx application entrypoint |
| 274 | + """ |
| 275 | + |
| 276 | + # Load overrides |
| 277 | + app.add_css_file("css/theme_overrides.css") |
| 278 | + |
| 279 | + # Read the replacement variables and the configuration values |
| 280 | + print("Device Family Build setup started") |
| 281 | + interpretvalues.read_familyvals(app, family_config_inputfile, |
| 282 | + family_replacevars, family_configvals) |
| 283 | + |
| 284 | + print("Build setup: Filled Replacement Variables (family_replacevars)" |
| 285 | + "and Configuration Values (family_configvals) hash tables") |
| 286 | + print("family_replacevars = ") |
| 287 | + print(family_replacevars) |
| 288 | + print("family_configvals = ") |
| 289 | + print(family_configvals) |
| 290 | + |
| 291 | + # Determine which sections need to be excluded |
| 292 | + sectinc.find_all_rst_files(app, exclude_patterns) |
| 293 | + sectinc.fill_docs_to_keep(app, family_tocfiles, 0) |
| 294 | + sectinc.set_excluded_docs(app, exclude_patterns) |
| 295 | + print(FAMILY + " exclude_patterns is:") |
| 296 | + print('[') |
| 297 | + for elem in exclude_patterns: |
| 298 | + print(elem) |
| 299 | + print(']') |
| 300 | + |
| 301 | + # Write to the replacevars.rst.inc file for usage by Sphinx |
| 302 | + replacevars.write_replacevars(app, family_replacevars) |
| 303 | + print("Device Family Build setup completed") |
0 commit comments