From ba8569f131f0031b3785657751c684e5df59948e Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 18 Mar 2018 12:32:23 +0900 Subject: [PATCH] Do not construct tag by python code --- sphinx/builders/qthelp.py | 39 ++++++++++++++--------------- sphinx/templates/qthelp/project.qhp | 4 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py index ef729e420..4c1016708 100644 --- a/sphinx/builders/qthelp.py +++ b/sphinx/builders/qthelp.py @@ -42,7 +42,6 @@ _idpattern = re.compile( section_template = '
' -file_template = ' ' * 12 + '%(filename)s' def render_file(filename, **kwargs): @@ -132,24 +131,6 @@ class QtHelpBuilder(StandaloneHTMLBuilder): keywords.extend(self.build_keywords(title, refs, subitems)) keywords = u'\n'.join(keywords) # type: ignore - # files - if not outdir.endswith(os.sep): - outdir += os.sep - olen = len(outdir) - projectfiles = [] - staticdir = path.join(outdir, '_static') - imagesdir = path.join(outdir, self.imagedir) - for root, dirs, files in os.walk(outdir): - resourcedir = root.startswith(staticdir) or \ - root.startswith(imagesdir) - for fn in sorted(files): - if (resourcedir and not fn.endswith('.js')) or \ - fn.endswith('.html'): - filename = path.join(root, fn)[olen:] - projectfiles.append(file_template % - {'filename': htmlescape(filename)}) - projectfiles = '\n'.join(projectfiles) # type: ignore - # it seems that the "namespace" may not contain non-alphanumeric # characters, and more than one successive dot, or leading/trailing # dots, are also forbidden @@ -168,7 +149,8 @@ class QtHelpBuilder(StandaloneHTMLBuilder): title=self.config.html_title, version=self.config.version, project=self.config.project, namespace=nspace, master_doc=self.config.master_doc, - sections=sections, keywords=keywords, files=projectfiles) + sections=sections, keywords=keywords, + files=self.get_project_files(outdir)) f.write(content) homepage = 'qthelp://' + posixpath.join( @@ -274,6 +256,23 @@ class QtHelpBuilder(StandaloneHTMLBuilder): return keywords + def get_project_files(self, outdir): + # type: (unicode) -> List[unicode] + if not outdir.endswith(os.sep): + outdir += os.sep + olen = len(outdir) + project_files = [] + staticdir = path.join(outdir, '_static') + imagesdir = path.join(outdir, self.imagedir) + for root, dirs, files in os.walk(outdir): + resourcedir = root.startswith((staticdir, imagesdir)) + for fn in sorted(files): + if (resourcedir and not fn.endswith('.js')) or fn.endswith('.html'): + filename = path.join(root, fn)[olen:] + project_files.append(filename) + + return project_files + def setup(app): # type: (Sphinx) -> Dict[unicode, Any] diff --git a/sphinx/templates/qthelp/project.qhp b/sphinx/templates/qthelp/project.qhp index 92a7af0e8..53f999043 100644 --- a/sphinx/templates/qthelp/project.qhp +++ b/sphinx/templates/qthelp/project.qhp @@ -18,7 +18,9 @@ {{ keywords }} -{{ files }} + {%- for filename in files %} + {{ filename|e }} + {%- endfor %}