Skip to content

[Docs] Allow building man pages without myst_parser #82402

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

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

cor3ntin
Copy link
Contributor

@cor3ntin cor3ntin commented Feb 20, 2024

The man pages do not depend on the doc present in markdown files, so they can be built without myst_parser.
Doing so might allow llvm distributions to have less development dependencies.

As we do not have the ennvironment to test these configuration, this capability is provided on a best-effort basis.

This restores a capability accidentally lost in #65664.

The pan pages do not depend on the doc present in markdown files,
so they can be built without myst_parser.
Doing so might allow llvm distributions to have less development
dependencies.

As we do not have the ennvironment to test these configuration, this
capability is provided on a best-effort basis.

This restores a capability accidentally lost in llvm#65664.
@llvmbot llvmbot added clang Clang issues not falling into any other category flang Flang issues not falling into any other category labels Feb 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)

Changes

The pan pages do not depend on the doc present in markdown files, so they can be built without myst_parser.
Doing so might allow llvm distributions to have less development dependencies.

As we do not have the ennvironment to test these configuration, this capability is provided on a best-effort basis.

This restores a capability accidentally lost in #65664.


Full diff: https://github.com/llvm/llvm-project/pull/82402.diff

3 Files Affected:

  • (modified) clang/docs/conf.py (+10-2)
  • (modified) flang/docs/conf.py (+11-1)
  • (modified) llvm/docs/conf.py (+11-1)
diff --git a/clang/docs/conf.py b/clang/docs/conf.py
index 31a4daa39d5b8e..44fd743dc0173f 100644
--- a/clang/docs/conf.py
+++ b/clang/docs/conf.py
@@ -35,8 +35,16 @@
 
 import sphinx
 
-if sphinx.version_info >= (3, 0):
-    extensions.append("myst_parser")
+# When building man pages, we do not use the markdown pages,
+# So, we can continue without the myst_parser dependencies.
+# Doing so reduces dependencies of some packaged llvm distributions.
+try:
+  import myst_parser
+  extensions.append("myst_parser")
+except ImportError:
+  if not tags.has("builder-man"):
+    raise
+
 
 # The encoding of source files.
 # source_encoding = 'utf-8-sig'
diff --git a/flang/docs/conf.py b/flang/docs/conf.py
index a34f7bf4a2100b..121c8f34a1ec61 100644
--- a/flang/docs/conf.py
+++ b/flang/docs/conf.py
@@ -22,13 +22,23 @@
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = [
-    "myst_parser",
     "sphinx.ext.todo",
     "sphinx.ext.mathjax",
     "sphinx.ext.intersphinx",
     "sphinx.ext.autodoc",
 ]
 
+# When building man pages, we do not use the markdown pages,
+# So, we can continue without the myst_parser dependencies.
+# Doing so reduces dependencies of some packaged llvm distributions.
+try:
+  import myst_parser
+  extensions.append("myst_parser")
+except ImportError:
+  if not tags.has("builder-man"):
+    raise
+
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ["_templates"]
 myst_heading_anchors = 6
diff --git a/llvm/docs/conf.py b/llvm/docs/conf.py
index 0a3905201c8592..54e45badff79df 100644
--- a/llvm/docs/conf.py
+++ b/llvm/docs/conf.py
@@ -26,7 +26,17 @@
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ["myst_parser", "sphinx.ext.intersphinx", "sphinx.ext.todo"]
+extensions = ["sphinx.ext.intersphinx", "sphinx.ext.todo"]
+
+# When building man pages, we do not use the markdown pages,
+# So, we can continue without the myst_parser dependencies.
+# Doing so reduces dependencies of some packaged llvm distributions.
+try:
+  import myst_parser
+  extensions.append("myst_parser")
+except ImportError:
+  if not tags.has("builder-man"):
+    raise
 
 # Automatic anchors for markdown titles
 from llvm_slug import make_slug

Copy link

github-actions bot commented Feb 20, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look reasonable to me, but I'd appreciate a final sign off from @mgorny to make sure this works for his needs.

@cor3ntin cor3ntin requested review from AaronBallman and mgorny and removed request for mgorny February 22, 2024 09:28
Copy link
Member

@mgorny mgorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. From a quick test run with and without myst-parser, this seems to work as intended.

# So, we can continue without the myst_parser dependencies.
# Doing so reduces dependencies of some packaged llvm distributions.
try:
import myst_parser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're using different indentation (2 spaces) vs other code in that file (4 spaces).

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from the formatting issue @mgorny mentioned.

@cor3ntin cor3ntin merged commit 7d55a3b into llvm:main Mar 4, 2024
@cor3ntin cor3ntin deleted the gentoo_man_pages branch March 4, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category documentation flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants