|
11 | 11 | # SPDX-License-Identifier: Apache-2.0 |
12 | 12 | # ******************************************************************************* |
13 | 13 | import json |
14 | | -import os |
15 | 14 | from copy import deepcopy |
16 | 15 | from pathlib import Path |
17 | | -from pprint import pprint |
18 | 16 |
|
19 | | -from src.extensions.score_source_code_linker.parse_source_files import GITHUB_BASE_URL |
20 | 17 | from sphinx.application import Sphinx |
21 | 18 | from sphinx.environment import BuildEnvironment |
22 | 19 | from sphinx_needs.data import SphinxNeedsData |
23 | 20 | from sphinx_needs.logging import get_logger |
24 | 21 |
|
| 22 | +from src.extensions.score_source_code_linker.parse_source_files import GITHUB_BASE_URL |
| 23 | + |
25 | 24 | LOGGER = get_logger(__name__) |
26 | 25 | LOGGER.setLevel("DEBUG") |
27 | 26 |
|
28 | 27 |
|
29 | 28 | def setup(app: Sphinx) -> dict[str, str | bool]: |
30 | 29 | # Extension: score_source_code_linker |
31 | | - app.add_config_value("disable_source_code_linker", False, rebuild="env") |
32 | | - app.add_config_value("score_source_code_linker_file_overwrite", "", rebuild="env") |
33 | 30 | # TODO: can we detect live_preview & esbonio here? Until then we have a flag: |
| 31 | + app.add_config_value("disable_source_code_linker", False, rebuild="env", types=bool) |
| 32 | + app.add_config_value( |
| 33 | + "score_source_code_linker_file_overwrite", "", rebuild="env", types=str |
| 34 | + ) |
34 | 35 |
|
35 | 36 | # Define need_string_links here to not have it in conf.py |
36 | 37 | app.config.needs_string_links = { |
@@ -73,40 +74,17 @@ def add_source_link(app: Sphinx, env: BuildEnvironment) -> None: |
73 | 74 | Needs_Data = SphinxNeedsData(env) |
74 | 75 | needs = Needs_Data.get_needs_mutable() |
75 | 76 | needs_copy = deepcopy(needs) |
76 | | - # bazel-out/k8-fastbuild/bin/process-docs/incremental.runfiles/_main/process-docs/score_source_code_parser.json |
77 | | - # bazel-out/k8-fastbuild/bin/process-docs/incremental.runfiles/_main/tooling/extensions/score_source_code_linker/__init__.py |
78 | | - # bazel-out/k8-fastbuild/bin/process-docs/score_source_code_parser.json |
79 | | - # /home/vscode/.cache/bazel/_bazel_vscode/6084288f00f33db17acb4220ce8f1999/execroot/_main/bazel-out/k8-fastbuild/bin/process-docs/incremental.runfiles/score_source_code_parser.json |
80 | | - # |
81 | | - |
82 | | - ## -> build: |
83 | | - |
84 | | - # bazel-out/k8-opt-exec-ST-d57f47055a04/bin/tooling/sphinx_build.runfiles/_main/tooling/extensions/score_source_code_linker/__init__.py |
85 | | - |
86 | | - # Tried with build |
87 | | - # bazel-out/k8-fastbuild/bin/process-docs/_docs/_sources/process-docs/score_source_code_parser.json |
88 | | - |
89 | | - # SEARCHING: |
90 | | - # bazel-out/k8-opt-exec-ST-d57f47055a04/bin/process-docs/score_source_code_parser.json |
91 | 77 | p5 = Path(__file__).parents[5] |
92 | 78 |
|
93 | | - # bazel-out/k8-opt-exec-ST-d57f47055a04/bin/tooling |
94 | | - # LOGGER.info("DEBUG: ============= CONF DIR===========") |
95 | | - # LOGGER.info(f"DEBUG: {Path(app.confdir).name}") |
96 | | - # LOGGER.info("DEBUG: =============================") |
97 | 79 | if str(p5).endswith("src"): |
98 | 80 | LOGGER.info("DEBUG: WE ARE IN THE IF") |
99 | 81 | path = str(p5.parent / Path(app.confdir).name / "score_source_code_parser.json") |
100 | 82 | else: |
101 | 83 | LOGGER.info("DEBUG: WE ARE IN THE ELSE") |
102 | 84 | path = str(p5 / "score_source_code_parser.json") |
103 | | - # LOGGER.info("DEBUG============= FILE PATH OF JSON (where we search)===========") |
104 | | - # LOGGER.info(f"DEBUG: {path}") |
105 | | - # LOGGER.info("DEBUG: =============================") |
| 85 | + |
106 | 86 | if app.config.score_source_code_linker_file_overwrite: |
107 | 87 | path = app.config.score_source_code_linker_file_overwrite |
108 | | - # json_paths = [str(Path(__file__).parent.parent.parent.parent.parent.parent/"score_source_code_parser.json")] |
109 | | - # json_paths = [app.config.source_code_linker_file] |
110 | 88 |
|
111 | 89 | try: |
112 | 90 | with open(path) as f: |
|
0 commit comments