Skip to content

Commit

Permalink
fix: build Markdown relative to input directory (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandhlee committed May 7, 2024
1 parent e358870 commit 2a4b9fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def build_init(app):
print("Successfully retrieved repository metadata.")
app.env.library_shortname = repo_metadata["name"]
print("Running sphinx-build with Markdown first...")
markdown_utils.run_sphinx_markdown()
markdown_utils.run_sphinx_markdown(app)
print("Completed running sphinx-build with Markdown files.")

"""
Expand Down
8 changes: 5 additions & 3 deletions docfx_yaml/markdown_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,11 @@ def remove_unused_pages(
print(f"Could not delete {page}.")


def run_sphinx_markdown() -> None:
def run_sphinx_markdown(app: sphinx.application) -> None:
"""Runs sphinx-build with Markdown builder in the plugin."""
cwd = os.getcwd()
relative_srcdir = app.srcdir.removeprefix(f"{cwd}/")
relative_outdir = app.outdir.removeprefix(f"{cwd}/").removesuffix("/html")
# Skip running sphinx-build for Markdown for some unit tests.
# Not required other than to output DocFX YAML.
if "docs" in cwd:
Expand All @@ -498,8 +500,8 @@ def run_sphinx_markdown() -> None:
"sphinx-build",
"-M",
"markdown",
"docs/",
"docs/_build",
relative_srcdir,
relative_outdir,
],
hide_output=False
)
Expand Down

0 comments on commit 2a4b9fe

Please sign in to comment.