Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/sphinx-codelinks/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ New and Improved
Sphinx-Needs workspace declares and type-checks against. There is no upper bound: Sphinx
caps docutils per series itself.

- 馃悰 ``src_trace_projects`` declared directly in ``conf.py`` are normalised before
``src-trace`` reads them.

Projects configured without ``ubproject.toml`` now get the same typed
``source_discover_config`` and ``analyse_config`` objects as TOML-backed projects, so a
``src-trace`` directive no longer fails with ``KeyError: 'source_discover_config'``.

- 馃悰 ``sphinx_codelinks.__version__`` reported ``"0.1.0"``.

It had said so since the first commit, through seven releases, while the distribution
Expand Down
3 changes: 3 additions & 0 deletions packages/sphinx-codelinks/src/sphinx_codelinks/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ class CodeLinksConfig:
@classmethod
def from_sphinx(cls, sphinx_config: _SphinxConfig) -> "CodeLinksConfig":
obj = cls()
src_trace_projects = getattr(sphinx_config, "src_trace_projects", None)
if isinstance(src_trace_projects, dict):
generate_project_configs(src_trace_projects)
super().__setattr__(obj, "_sphinx_config", sphinx_config)
return obj

Expand Down
26 changes: 26 additions & 0 deletions packages/sphinx-codelinks/tests/test_src_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,32 @@ def _traced_project(root: Path, conf_extra: str, files: dict[str, str]) -> None:
_PROJECT_P = '[codelinks.projects.p.source_discover]\nsrc_dir = "./src"\ncomment_type = "python"\n'


def test_conf_py_projects_are_normalized_for_src_trace(
tmp_path: Path,
make_app: Callable[..., SphinxTestApp],
) -> None:
"""Projects declared in ``conf.py`` get the same typed config as TOML projects."""
_traced_project(
tmp_path,
"src_trace_config_from_toml = None\n"
"src_trace_projects = {\n"
" 'p': {\n"
" 'source_discover': {\n"
" 'src_dir': './src',\n"
" 'comment_type': 'python',\n"
" },\n"
" 'analyse': {},\n"
" },\n"
"}\n",
{"src/a.py": _MARKER.format(tag="CONFPY")},
)
app = make_app(srcdir=tmp_path, freshenv=True)
app.build()

html = Path(app.outdir, "index.html").read_text(encoding="utf-8")
assert "IMPL_CONFPY" in html


def test_symlinked_toml_anchors_at_the_links_directory(
tmp_path: Path,
make_app: Callable[..., SphinxTestApp],
Expand Down
Loading