From bd891fbdf4ee755044013ccff020f01b587ed507 Mon Sep 17 00:00:00 2001 From: Andrea Gavana Date: Sat, 1 Dec 2012 22:38:22 +0000 Subject: [PATCH] Phoenix: converted snippets for `xml` and `xrc`. Fixed minor issues in the docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- .../python/converted/xml.XmlDocument.1.py | 41 +++++++++++++++++++ .../python/converted/xml.XmlDocument.2.py | 6 +++ .../python/converted/xml.XmlDocument.3.py | 4 ++ .../converted/xml.XmlNode.GetNodeContent.1.py | 4 ++ .../converted/xml.XmlNode.GetNodeContent.2.py | 4 ++ .../converted/xrc.XmlResource.Load.1.py | 3 ++ .../converted/xrc.XmlResource.LoadDialog.1.py | 3 ++ etgtools/sphinx_generator.py | 2 +- sphinxtools/constants.py | 2 +- 9 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.1.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.2.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.3.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.1.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.2.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.Load.1.py create mode 100644 docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.LoadDialog.1.py diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.1.py new file mode 100644 index 00000000..2a786908 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.1.py @@ -0,0 +1,41 @@ + + doc = wx.xml.XmlDocument() + if not doc.Load("myfile.xml"): + return False + + # start processing the XML file + if doc.GetRoot().GetName() != "myroot-node": + return False + + # examine prologue + prolog = doc.GetDocumentNode().GetChildren() + while prolog: + + if prolog.GetType() == wx.xml.XML_PI_NODE and prolog.GetName() == "target": + + # process Process Instruction contents + pi = prolog.GetContent() + + # Other code here... + + child = doc.GetRoot().GetChildren() + while child: + + if child.GetName() == "tag1": + + # process text enclosed by tag1/tag1 + content = child.GetNodeContent() + + # Other code here... + + # process attributes of tag1 + attrvalue1 = child.GetAttribute("attr1", "default-value") + attrvalue2 = child.GetAttribute("attr2", "default-value") + + elif child.GetName() == "tag2": + + # process tag2 ... + attrvalue3 = child.GetAttribute("attr3", "default-value") + + + child = child.GetNext() diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.2.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.2.py new file mode 100644 index 00000000..1b92baa7 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.2.py @@ -0,0 +1,6 @@ + + doc = wx.xml.XmlDocument() + doc.Load("myfile.xml", "UTF-8", wx.xml.XMLDOC_KEEP_WHITESPACE_NODES) + + # myfile2.xml will be identical to myfile.xml saving it self way: + doc.Save("myfile2.xml", wx.xml.XML_NO_INDENTATION) diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.3.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.3.py new file mode 100644 index 00000000..788fec29 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlDocument.3.py @@ -0,0 +1,4 @@ + + doc = wx.xml.XmlDocument() + doc.Load("myfile.xml") + doc.Save("myfile2.xml") # myfile2.xml != myfile.xml diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.1.py new file mode 100644 index 00000000..83729ee2 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.1.py @@ -0,0 +1,4 @@ + # .. code-block:: text + + XML_ELEMENT_NODE name="tagname", content="" + |-- XML_TEXT_NODE name="", content="tagcontent" diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.2.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.2.py new file mode 100644 index 00000000..a410fcbb --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xml.XmlNode.GetNodeContent.2.py @@ -0,0 +1,4 @@ + # .. code-block:: text + + XML_ELEMENT_NODE name="tagname", content="" + |-- XML_CDATA_SECTION_NODE name="", content="tagcontent" diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.Load.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.Load.1.py new file mode 100644 index 00000000..b6222caf --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.Load.1.py @@ -0,0 +1,3 @@ + + if not wx.xml.XmlResource.Get().Load("rc/*.xrc")) + wx.LogError("Couldn't load resources!") diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.LoadDialog.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.LoadDialog.1.py new file mode 100644 index 00000000..be7780c1 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/xrc.XmlResource.LoadDialog.1.py @@ -0,0 +1,3 @@ + + dlg = wx.xml.XmlResource.Get().LoadDialog(mainFrame, "my_dialog") + dlg.ShowModal() diff --git a/etgtools/sphinx_generator.py b/etgtools/sphinx_generator.py index c3dcebc4..0aa49f45 100644 --- a/etgtools/sphinx_generator.py +++ b/etgtools/sphinx_generator.py @@ -2355,7 +2355,6 @@ class XMLDocString(object): found = False for line in py_docs.splitlines(): - if line.startswith(name): if not found: newlines.append("**Possible constructors**::\n") @@ -2365,6 +2364,7 @@ class XMLDocString(object): newlines.append(ConvertToPython(line)) if found: + line = line.replace('wx.EmptyString', '""') newlines = self.CodeIndent(line, newlines) newdocs = '' diff --git a/sphinxtools/constants.py b/sphinxtools/constants.py index 947e0b68..de02202d 100644 --- a/sphinxtools/constants.py +++ b/sphinxtools/constants.py @@ -25,7 +25,7 @@ IGNORE = ['wxPython', 'wxWidgets', 'wxOSX', 'wxMGL', 'wxDFB', 'wxMAC', 'wxGTK', 'OS', 'X', 'OSX', 'DFB', 'MAC', 'GTK', 'GTK2', 'MSW', 'wxMSW', 'X11', 'OS2', 'MS', 'XP', 'GTK+', 'UI', 'GUI', '--', 'OTOH', 'GDI+', 'API', 'NT', 'RTL', 'GDI', '3D', 'MDI', 'SDI', 'TDI', 'URL', 'XPM', 'HTML', 'MIME', 'C++', 'XDG', 'A4', 'A5', 'KDE', 'GNOME', 'XFCE', 'CSS', 'IE', 'FONT', - 'SIZE', 'COLOR'] + 'SIZE', 'COLOR', 'NOT', 'DOES'] # C++ stuff to Python/ReST stuff VALUE_MAP = {'true': '``True``',