summaryrefslogtreecommitdiff
path: root/grc/python
diff options
context:
space:
mode:
Diffstat (limited to 'grc/python')
-rw-r--r--grc/python/Block.py7
-rw-r--r--grc/python/Platform.py25
-rw-r--r--grc/python/extract_docs.py2
3 files changed, 19 insertions, 15 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py
index f5c994dc05..f43b006e5f 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -185,8 +185,11 @@ class Block(_Block, _GUIBlock):
def get_doc(self):
platform = self.get_parent().get_parent()
- extracted_docs = platform.block_docstrings.get(self._key, '')
- return (self._doc + '\n\n' + extracted_docs).strip()
+ documentation = platform.block_docstrings.get(self._key, {})
+ from_xml = self._doc.strip()
+ if from_xml:
+ documentation[''] = from_xml
+ return documentation
def get_category(self):
return _Block.get_category(self)
diff --git a/grc/python/Platform.py b/grc/python/Platform.py
index 1d932761d8..5932818c1e 100644
--- a/grc/python/Platform.py
+++ b/grc/python/Platform.py
@@ -38,8 +38,6 @@ from .Constants import (
PREFS_FILE, PREFS_FILE_OLD, CORE_TYPES
)
-COLORS = [(name, color) for name, key, sizeof, color in CORE_TYPES]
-
class Platform(_Platform, _GUIPlatform):
def __init__(self):
@@ -52,17 +50,11 @@ class Platform(_Platform, _GUIPlatform):
if not os.path.exists(os.path.dirname(PREFS_FILE)):
os.mkdir(os.path.dirname(PREFS_FILE))
- self.block_docstrings = block_docstrings = dict()
- self.block_docstrings_loaded_callback = lambda: None
-
- def setter(key, docs):
- block_docstrings[key] = '\n\n'.join(
- '--- {0} ---\n{1}\n'.format(b, d.replace('\n\n', '\n'))
- for b, d in docs.iteritems() if d is not None
- )
+ self.block_docstrings = {}
+ self.block_docstrings_loaded_callback = lambda: None # dummy to be replaced by BlockTreeWindow
self._docstring_extractor = extract_docs.SubprocessLoader(
- callback_query_result=setter,
+ callback_query_result=self._save_docstring_extraction_result,
callback_finished=lambda: self.block_docstrings_loaded_callback()
)
@@ -78,7 +70,7 @@ class Platform(_Platform, _GUIPlatform):
block_dtd=BLOCK_DTD,
default_flow_graph=DEFAULT_FLOW_GRAPH,
generator=Generator,
- colors=COLORS,
+ colors=[(name, color) for name, key, sizeof, color in CORE_TYPES],
)
self._move_old_pref_file()
_GUIPlatform.__init__(
@@ -87,6 +79,15 @@ class Platform(_Platform, _GUIPlatform):
)
self._auto_hier_block_generate_chain = set()
+ def _save_docstring_extraction_result(self, key, docstrings):
+ docs = {}
+ for match, docstring in docstrings.iteritems():
+ if not docstring or match.endswith('_sptr'):
+ continue
+ docstring = docstring.replace('\n\n', '\n').strip()
+ docs[match] = docstring
+ self.block_docstrings[key] = docs
+
@staticmethod
def _move_old_pref_file():
if PREFS_FILE == PREFS_FILE_OLD:
diff --git a/grc/python/extract_docs.py b/grc/python/extract_docs.py
index d8dc4f4e8f..7c149ce593 100644
--- a/grc/python/extract_docs.py
+++ b/grc/python/extract_docs.py
@@ -70,7 +70,7 @@ def docstring_guess_from_key(key):
)
for match in filter(pattern.match, dir(module)):
try:
- doc_strings[match] = getattr(module, match).__doc__.strip()
+ doc_strings[match] = getattr(module, match).__doc__
except AttributeError:
continue