diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-08-25 16:55:07 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-08-26 18:14:07 +0900 |
commit | 17fbf439c6056e119cae9923f46780529dab55d8 (patch) | |
tree | 5f982009364bce3426d763020bde6802158b2515 /sphinx/builders/devhelp.py | |
parent | 9f7afa161e34b98eaa8eb9ed826aa8a229c8d8cb (diff) | |
download | sphinx-git-17fbf439c6056e119cae9923f46780529dab55d8.tar.gz |
Apply NodeMatcher to Sphinx
Diffstat (limited to 'sphinx/builders/devhelp.py')
-rw-r--r-- | sphinx/builders/devhelp.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py index fc2c0b1c9..f81154984 100644 --- a/sphinx/builders/devhelp.py +++ b/sphinx/builders/devhelp.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import gzip import re from os import path +from typing import Any from docutils import nodes @@ -23,6 +24,7 @@ from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.environment.adapters.indexentries import IndexEntries from sphinx.locale import __ from sphinx.util import logging +from sphinx.util.nodes import NodeMatcher from sphinx.util.osutil import make_filename try: @@ -32,7 +34,7 @@ except ImportError: if False: # For type annotation - from typing import Any, Dict, List # NOQA + from typing import Dict, List # NOQA from sphinx.application import Sphinx # NOQA @@ -100,12 +102,8 @@ class DevhelpBuilder(StandaloneHTMLBuilder): parent.attrib['link'] = node['refuri'] parent.attrib['name'] = node.astext() - def istoctree(node): - # type: (nodes.Node) -> bool - return isinstance(node, addnodes.compact_paragraph) and \ - 'toctree' in node - - for node in tocdoc.traverse(istoctree): + matcher = NodeMatcher(addnodes.compact_paragraph, toctree=Any) + for node in tocdoc.traverse(matcher): write_toc(node, chapters) # Index |