Skip to content
Merged
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
1 change: 1 addition & 0 deletions yardang/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use_llms = {{use_llms}} # noqa: F821
# BASE EXTENSIONS #
###################
extensions = [
"yardang.sphinx",
"myst_nb",
"sphinx.ext.napoleon",
"sphinx_design",
Expand Down
10 changes: 10 additions & 0 deletions yardang/sphinx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from yardang import __version__


def setup(_app) -> dict[str, object]:
"""Register Yardang as a Sphinx extension."""
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}
24 changes: 24 additions & 0 deletions yardang/tests/test_sphinx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pathlib import Path

from yardang import __version__
from yardang.build import generate_docs_configuration
from yardang.sphinx import setup


def test_setup_returns_extension_metadata():
assert setup(None) == {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}


def test_generated_configuration_enables_extension(tmp_path, monkeypatch):
(tmp_path / "pyproject.toml").write_text('[project]\nname = "test-project"\nversion = "1.0.0"\n')
(tmp_path / "README.md").write_text("# Test Project\n")
monkeypatch.chdir(tmp_path)

with generate_docs_configuration() as conf_dir:
conf_content = (Path(conf_dir) / "conf.py").read_text()

assert '"yardang.sphinx"' in conf_content