From f13a31694d48868d54c3f8c6224e07e601ae7b59 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Jan 2012 23:40:48 +0000 Subject: [PATCH] Don't always append output to the ReST files. Classes and Enums should just replace the existing file if there is one. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@70244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etgtools/sphinx_generator.py | 16 ++++++++-------- sphinxtools/utilities.py | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/etgtools/sphinx_generator.py b/etgtools/sphinx_generator.py index e09d23a9..7733c194 100644 --- a/etgtools/sphinx_generator.py +++ b/etgtools/sphinx_generator.py @@ -2380,7 +2380,7 @@ class XMLDocString(object): stream.write("\n\n") if not self.is_overload and write: - WriteSphinxOutput(stream, self.output_file) + WriteSphinxOutput(stream, self.output_file, append=True) return stream.getvalue() @@ -2468,13 +2468,13 @@ class XMLDocString(object): text_file = os.path.join(SPHINXROOT, self.output_file) - if os.path.isfile(text_file): - message = '\nWARNING: Duplicated description for `%s` enumeration.\n\n' \ - 'The duplicated instance will still be written to its output ReST file but\n' \ - 'Sphinx/Docutils will issue a warning when building the HTML docs.\n\n' - - duplicated = self.output_file.replace('.enumeration.txt', '') - print message % duplicated + #if os.path.isfile(text_file): + # message = '\nWARNING: Duplicated description for `%s` enumeration.\n\n' \ + # 'The duplicated instance will still be written to its output ReST file but\n' \ + # 'Sphinx/Docutils will issue a warning when building the HTML docs.\n\n' + # + # duplicated = self.output_file.replace('.enumeration.txt', '') + # print message % duplicated if count > 0 and write: WriteSphinxOutput(stream, self.output_file) diff --git a/sphinxtools/utilities.py b/sphinxtools/utilities.py index 7649ed20..7d6baf7f 100644 --- a/sphinxtools/utilities.py +++ b/sphinxtools/utilities.py @@ -458,7 +458,7 @@ def MakeSummary(name, item_list, template, kind): # ----------------------------------------------------------------------- # -def WriteSphinxOutput(stream, filename): +def WriteSphinxOutput(stream, filename, append=False): """ Writes the text contained in the `stream` to the `filename` output file. @@ -469,10 +469,10 @@ def WriteSphinxOutput(stream, filename): text_file = os.path.join(SPHINXROOT, filename) text = stream.getvalue() - if not os.path.isfile(text_file): - text = '.. include:: headings.inc\n\n' + text - - fid = codecs.open(text_file, "a", encoding='utf-8') + mode = 'a' if append else 'w' + fid = codecs.open(text_file, mode, encoding='utf-8') + if mode == 'w': + fid.write('.. include:: headings.inc\n\n') fid.write(text) fid.close()