Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 2a4b9fe

Browse files
authored
fix: build Markdown relative to input directory (#380)
1 parent e358870 commit 2a4b9fe

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

docfx_yaml/extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def build_init(app):
182182
print("Successfully retrieved repository metadata.")
183183
app.env.library_shortname = repo_metadata["name"]
184184
print("Running sphinx-build with Markdown first...")
185-
markdown_utils.run_sphinx_markdown()
185+
markdown_utils.run_sphinx_markdown(app)
186186
print("Completed running sphinx-build with Markdown files.")
187187

188188
"""

docfx_yaml/markdown_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,11 @@ def remove_unused_pages(
485485
print(f"Could not delete {page}.")
486486

487487

488-
def run_sphinx_markdown() -> None:
488+
def run_sphinx_markdown(app: sphinx.application) -> None:
489489
"""Runs sphinx-build with Markdown builder in the plugin."""
490490
cwd = os.getcwd()
491+
relative_srcdir = app.srcdir.removeprefix(f"{cwd}/")
492+
relative_outdir = app.outdir.removeprefix(f"{cwd}/").removesuffix("/html")
491493
# Skip running sphinx-build for Markdown for some unit tests.
492494
# Not required other than to output DocFX YAML.
493495
if "docs" in cwd:
@@ -498,8 +500,8 @@ def run_sphinx_markdown() -> None:
498500
"sphinx-build",
499501
"-M",
500502
"markdown",
501-
"docs/",
502-
"docs/_build",
503+
relative_srcdir,
504+
relative_outdir,
503505
],
504506
hide_output=False
505507
)

0 commit comments

Comments
 (0)