Skip to content

Commit

Permalink
🔖 3.19
Browse files Browse the repository at this point in the history
Copied files from https://gitlab.kitware.com/cmake/cmake/-/tree/v3.19.3/Utilities/Sphinx

This fixes the warning:
RemovedInSphinx40Warning: The alias 'sphinx.util.pycompat.htmlescape' is deprecated, use 'html.escape' instead. Check CHANGES for Sphinx API modifications.

RemovedInSphinx40Warning: The alias 'sphinx.builders.qthelp.QtHelpBuilder' is deprecated, use 'sphinxcontrib.qthelp.QtHelpBuilder' instead. Check CHANGES for Sphinx API modifications.
  from .cmake import setup

Which was fixed in CMake repo with this MR:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5326

Signed-off-by: Stefan Profanter <[email protected]>
  • Loading branch information
Pro authored and bruxisma committed Jan 28, 2021
1 parent 2b18e3c commit 65f73af
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = sphinxcontrib-moderncmakedomain
version = 3.17
version = 3.19
long_description_content_type = text/markdown
long_description= file: README.md
author_email =
Expand Down
54 changes: 27 additions & 27 deletions sphinxcontrib/moderncmakedomain/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,6 @@
# (r'[^<>\])\}\|$"# \t\n]+', Name.Exception), # fallback, for debugging only
]

# Monkey patch for sphinx generating invalid content for qcollectiongenerator
# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords
from sphinx.util.pycompat import htmlescape
from sphinx.builders.qthelp import QtHelpBuilder
old_build_keywords = QtHelpBuilder.build_keywords
def new_build_keywords(self, title, refs, subitems):
old_items = old_build_keywords(self, title, refs, subitems)
new_items = []
for item in old_items:
before, rest = item.split("ref=\"", 1)
ref, after = rest.split("\"")
if ("<" in ref and ">" in ref):
new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after)
else:
new_items.append(item)
return new_items
QtHelpBuilder.build_keywords = new_build_keywords


from docutils.parsers.rst import Directive, directives
from docutils.transforms import Transform
try:
Expand All @@ -92,18 +73,37 @@ def new_build_keywords(self, title, refs, subitems):
from sphinx.util.nodes import make_refnode
from sphinx import addnodes

# Needed for checking if Sphinx version is >= 1.4.
# See https://github.com/sphinx-doc/sphinx/issues/2673
old_sphinx = False

sphinx_before_1_4 = False
sphinx_before_1_7_2 = False
try:
from sphinx import version_info
if version_info < (1, 4):
old_sphinx = True
sphinx_before_1_4 = True
if version_info < (1, 7, 2):
sphinx_before_1_7_2 = True
except ImportError:
# The `sphinx.version_info` tuple was added in Sphinx v1.2:
old_sphinx = True

sphinx_before_1_4 = True
sphinx_before_1_7_2 = True

if sphinx_before_1_7_2:
# Monkey patch for sphinx generating invalid content for qcollectiongenerator
# https://github.com/sphinx-doc/sphinx/issues/1435
from sphinx.util.pycompat import htmlescape
from sphinx.builders.qthelp import QtHelpBuilder
old_build_keywords = QtHelpBuilder.build_keywords
def new_build_keywords(self, title, refs, subitems):
old_items = old_build_keywords(self, title, refs, subitems)
new_items = []
for item in old_items:
before, rest = item.split("ref=\"", 1)
ref, after = rest.split("\"")
if ("<" in ref and ">" in ref):
new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after)
else:
new_items.append(item)
return new_items
QtHelpBuilder.build_keywords = new_build_keywords

class CMakeModule(Directive):
required_arguments = 1
Expand Down Expand Up @@ -181,7 +181,7 @@ def __init__(self, desc):

def __call__(self, title, targetid, main = 'main'):
# See https://github.com/sphinx-doc/sphinx/issues/2673
if old_sphinx:
if sphinx_before_1_4:
return ('pair', u'%s ; %s' % (self.desc, title), targetid, main)
else:
return ('pair', u'%s ; %s' % (self.desc, title), targetid, main, None)
Expand Down

0 comments on commit 65f73af

Please sign in to comment.