summaryrefslogtreecommitdiff
path: root/grc/gui/PropsDialog.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-02-05 11:43:26 +0100
committerSebastian Koslowski <koslowski@kit.edu>2016-02-05 11:55:55 +0100
commitdec3bf564e5ca3b6fc103b3eb66a80e8abe8229b (patch)
tree8639e4ba8141460f3d9975cade1f902525fbeae4 /grc/gui/PropsDialog.py
parente21a3dad6cf8e035ff5104d9eddfce11a8582658 (diff)
grc: nicer block documentation tooltip and properties dialog tab
Diffstat (limited to 'grc/gui/PropsDialog.py')
-rw-r--r--grc/gui/PropsDialog.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py
index bf7d31d391..7c66a77a54 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -97,7 +97,8 @@ class PropsDialog(gtk.Dialog):
self._params_boxes.append((tab, label, vbox))
# Docs for the block
- self._docs_text_display = SimpleTextDisplay()
+ self._docs_text_display = doc_view = SimpleTextDisplay()
+ doc_view.get_buffer().create_tag('b', weight=pango.WEIGHT_BOLD)
self._docs_box = gtk.ScrolledWindow()
self._docs_box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._docs_box.add_with_viewport(self._docs_text_display)
@@ -200,10 +201,43 @@ class PropsDialog(gtk.Dialog):
messages = '\n\n'.join(self._block.get_error_messages())
self._error_messages_text_display.set_text(messages)
# update the docs box
- self._docs_text_display.set_text(self._block.get_doc())
+ self._update_docs_page()
# update the generated code
self._update_generated_code_page()
+ def _update_docs_page(self):
+ """Show documentation from XML and try to display best matching docstring"""
+ buffer = self._docs_text_display.get_buffer()
+ buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
+ pos = buffer.get_end_iter()
+
+ docstrings = self._block.get_doc()
+ if not docstrings:
+ return
+
+ # show documentation string from block xml
+ from_xml = docstrings.pop('', '')
+ for line in from_xml.splitlines():
+ if line.lstrip() == line and line.endswith(':'):
+ buffer.insert_with_tags_by_name(pos, line + '\n', 'b')
+ else:
+ buffer.insert(pos, line + '\n')
+ if from_xml:
+ buffer.insert(pos, '\n')
+
+ # if given the current parameters an exact match can be made
+ block_constructor = self._block.get_make().rsplit('.', 2)[-1]
+ block_class = block_constructor.partition('(')[0].strip()
+ if block_class in docstrings:
+ docstrings = {block_class: docstrings[block_class]}
+
+ # show docstring(s) extracted from python sources
+ for cls_name, docstring in docstrings.iteritems():
+ buffer.insert_with_tags_by_name(pos, cls_name + '\n', 'b')
+ buffer.insert(pos, docstring + '\n\n')
+ pos.backward_chars(2)
+ buffer.delete(pos, buffer.get_end_iter())
+
def _update_generated_code_page(self):
if not self._code_text_display:
return # user disabled code preview