Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified doc/make.py to run sphinx-build -b linkcheck #54265

Merged
merged 18 commits into from
Sep 19, 2023
Merged
Changes from 1 commit
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
29 changes: 27 additions & 2 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"""
import argparse
import csv
import docutils.frontend
import docutils.nodes
import importlib
import os
import shutil
Expand All @@ -21,6 +23,7 @@
import webbrowser

import docutils
import docutils.utils
import docutils.parsers.rst

DOC_PATH = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -288,9 +291,27 @@ def zip_html(self):
os.chdir(dirname)
self._run_os("zip", zip_fname, "-r", "-q", *fnames)

def _linkcheck(self):
"""
Check for broken links in the documentation.
"""
cmd = ["sphinx-build", "-b", "linkcheck"]
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved
if self.num_jobs:
cmd += ["-j", self.num_jobs]
if self.verbosity:
cmd.append(f"-{'v' * self.verbosity}")
cmd += [
"-d",
os.path.join(BUILD_PATH, "doctrees"),
SOURCE_PATH,
os.path.join(BUILD_PATH, "linkcheck"),
]
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved
subprocess.call(cmd)


def main():
cmds = [method for method in dir(DocBuilder) if not method.startswith("_")]
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved
cmds.append("linkcheck") # Add linkcheck to the available commands
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved

joined = ",".join(cmds)
argparser = argparse.ArgumentParser(
Expand Down Expand Up @@ -349,6 +370,7 @@ def main():
joined = ", ".join(cmds)
raise ValueError(f"Unknown command {args.command}. Available options: {joined}")


# Below we update both os.environ and sys.path. The former is used by
# external libraries (namely Sphinx) to compile this module and resolve
# the import of `python_path` correctly. The latter is used to resolve
Expand All @@ -369,8 +391,11 @@ def main():
args.verbosity,
args.warnings_are_errors,
)
return getattr(builder, args.command)()
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved


if args.command == "linkcheck":
ggold7046 marked this conversation as resolved.
Show resolved Hide resolved
builder._linkcheck() # Call the linkcheck method
else:
return getattr(builder, args.command)()

ggold7046 marked this conversation as resolved.
Show resolved Hide resolved
if __name__ == "__main__":
sys.exit(main())
Loading