diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-08-29 23:49:59 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 23:49:59 +0900 |
commit | db1582833d729701e2b8c400971d5c566c66e84c (patch) | |
tree | 625e6c48ec63886752eb789e61aa2a7bc0db47c3 /sphinx/builders/devhelp.py | |
parent | 92bd804b898a7ec2406f7abe1d451c8012e86097 (diff) | |
parent | 17fbf439c6056e119cae9923f46780529dab55d8 (diff) | |
download | sphinx-git-db1582833d729701e2b8c400971d5c566c66e84c.tar.gz |
Merge pull request #5346 from tk0miya/add_NodeMatcher
[Proposal] Add a helper class for Node.traverse()
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 |