summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorJosh Blum2011-11-17 07:59:50 -0800
committerJosh Blum2011-11-17 07:59:50 -0800
commit7b57dae20bb182561fcda78e5eeec44e44f0a9fb (patch)
tree8cffe26c338172ea9a9adbc953e199e048e77d30 /grc
parent11d58fe2e58c83fffae0153b3d541e9928f04411 (diff)
downloadgnuradio-7b57dae20bb182561fcda78e5eeec44e44f0a9fb.tar.gz
gnuradio-7b57dae20bb182561fcda78e5eeec44e44f0a9fb.tar.bz2
gnuradio-7b57dae20bb182561fcda78e5eeec44e44f0a9fb.zip
grc: replaced doxygen extracted docs with python docstrings
Diffstat (limited to 'grc')
-rw-r--r--grc/CMakeLists.txt3
-rw-r--r--grc/Makefile.am1
-rw-r--r--grc/grc.conf.in1
-rw-r--r--grc/python/Block.py3
-rw-r--r--grc/python/CMakeLists.txt1
-rw-r--r--grc/python/Constants.py1
-rw-r--r--grc/python/Makefile.am1
-rw-r--r--grc/python/extract_category.py61
-rw-r--r--grc/python/extract_docs.py58
9 files changed, 13 insertions, 117 deletions
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt
index 2d108ab4d..997aa56b1 100644
--- a/grc/CMakeLists.txt
+++ b/grc/CMakeLists.txt
@@ -66,7 +66,6 @@ CPACK_COMPONENT("grc"
########################################################################
# Create and install the grc conf file
########################################################################
-file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${GR_PKG_DOC_DIR} docdir)
file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${GRC_BLOCKS_DIR} blocksdir)
configure_file(
@@ -101,13 +100,11 @@ file(TO_NATIVE_PATH ${GR_PYTHON_DIR} GR_PYTHON_POSTFIX)
string(REPLACE "\\" "\\\\" GR_PYTHON_POSTFIX ${GR_PYTHON_POSTFIX})
CPACK_SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
- WriteRegStr HKLM ${HLKM_ENV} \\\"GR_DOC_DIR\\\" \\\"$INSTDIR\\\\${GR_DOC_DIR}\\\"
WriteRegStr HKLM ${HLKM_ENV} \\\"GRC_BLOCKS_PATH\\\" \\\"$INSTDIR\\\\${GRC_BLOCKS_PATH}\\\"
WriteRegStr HKLM \\\"SOFTWARE\\\\Python\\\\PythonCore\\\\2.7\\\\PythonPath\\\" \\\"gnuradio\\\" \\\"$INSTDIR\\\\${GR_PYTHON_POSTFIX}\\\"
")
CPACK_SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
- DeleteRegValue HKLM ${HLKM_ENV} \\\"GR_DOC_DIR\\\"
DeleteRegValue HKLM ${HLKM_ENV} \\\"GRC_BLOCKS_PATH\\\"
DeleteRegValue HKLM \\\"SOFTWARE\\\\Python\\\\PythonCore\\\\2.7\\\\PythonPath\\\" \\\"gnuradio\\\"
")
diff --git a/grc/Makefile.am b/grc/Makefile.am
index 9d473b4d3..addefcf36 100644
--- a/grc/Makefile.am
+++ b/grc/Makefile.am
@@ -44,7 +44,6 @@ BUILT_SOURCES += grc.conf
grc.conf: $(srcdir)/grc.conf.in Makefile
sed \
-e 's|@blocksdir[@]|$(grc_blocksdir)|g' \
- -e 's|@docdir[@]|$(gr_docdir)|g' \
$< > $@
endif
diff --git a/grc/grc.conf.in b/grc/grc.conf.in
index 9363ca981..ace604ace 100644
--- a/grc/grc.conf.in
+++ b/grc/grc.conf.in
@@ -3,6 +3,5 @@
# ~/.gnuradio/config.conf
[grc]
-doc_dir = @docdir@
global_blocks_path = @blocksdir@
local_blocks_path =
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 967a27ce9..2c334dfc2 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from .. base.Block import Block as _Block
from .. gui.Block import Block as _GUIBlock
import extract_docs
-import extract_category
class Block(_Block, _GUIBlock):
@@ -154,8 +153,6 @@ class Block(_Block, _GUIBlock):
return '\n'.join([doc, extract_docs.extract(self.get_key())]).strip('\n')
def get_category(self):
- category = extract_category.extract(self.get_key())
- #if category: return category
return _Block.get_category(self)
def get_imports(self):
diff --git a/grc/python/CMakeLists.txt b/grc/python/CMakeLists.txt
index 2075d126d..0871c7bd1 100644
--- a/grc/python/CMakeLists.txt
+++ b/grc/python/CMakeLists.txt
@@ -21,7 +21,6 @@
GR_PYTHON_INSTALL(FILES
convert_hier.py
expr_utils.py
- extract_category.py
extract_docs.py
Block.py
Connection.py
diff --git a/grc/python/Constants.py b/grc/python/Constants.py
index ab547ea27..1a65caf1c 100644
--- a/grc/python/Constants.py
+++ b/grc/python/Constants.py
@@ -25,7 +25,6 @@ _gr_prefs = gr.prefs()
#setup paths
PATH_SEP = {'/':':', '\\':';'}[os.path.sep]
-DOCS_DIR = os.environ.get('GR_DOC_DIR', _gr_prefs.get_string('grc', 'doc_dir', ''))
HIER_BLOCKS_LIB_DIR = os.path.join(os.path.expanduser('~'), '.grc_gnuradio')
BLOCKS_DIRS = filter( #filter blank strings
lambda x: x, PATH_SEP.join([
diff --git a/grc/python/Makefile.am b/grc/python/Makefile.am
index 67b71bc47..eb35b6fc1 100644
--- a/grc/python/Makefile.am
+++ b/grc/python/Makefile.am
@@ -25,7 +25,6 @@ ourpythondir = $(pkgpythondir)/grc/python
ourpython_PYTHON = \
convert_hier.py \
expr_utils.py \
- extract_category.py \
extract_docs.py \
Block.py \
Connection.py \
diff --git a/grc/python/extract_category.py b/grc/python/extract_category.py
deleted file mode 100644
index f9358f616..000000000
--- a/grc/python/extract_category.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Copyright 2009 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-GNU Radio Companion is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-"""
-
-from Constants import DOCS_DIR
-from lxml import etree
-import os
-import re
-
-DOXYGEN_TITLE_XPATH = '/doxygen/compounddef/title'
-DOXYGEN_CLASS_XPATH = '/doxygen/compounddef/innerclass'
-
-#map a group/category to a list of blocks
-_category_map = dict()
-
-#extract the group/category information
-docs_dir = os.path.join(DOCS_DIR, 'xml')
-if os.path.exists(docs_dir):
- group_file_matcher = re.compile('^group__\w*\..*$') #xml or xml.gz
- matches = filter(lambda f: group_file_matcher.match(f), os.listdir(docs_dir))
- for match in matches:
- try:
- xml_file = os.path.join(docs_dir, match)
- xml = etree.parse(xml_file)
- category = xml.xpath(DOXYGEN_TITLE_XPATH)[0].text
- blocks = map(lambda x: x.text, xml.xpath(DOXYGEN_CLASS_XPATH))
- _category_map[category] = blocks
- except: pass
-
-def extract(key):
- """
- Match the given key to a key in an existing category.
- If no match can be made, return an empty string.
- @param key the block key
- @return the category or empty string
- """
- pattern = key.replace('_', '_*').replace('x', '\w')
- class_name_matcher = re.compile('^%s$'%pattern)
- for category, blocks in _category_map.iteritems():
- for block in blocks:
- if class_name_matcher.match(block): return category
- return ''
-
-if __name__ == '__main__':
- import sys
- print extract(sys.argv[1])
diff --git a/grc/python/extract_docs.py b/grc/python/extract_docs.py
index fe157a221..a7e945c37 100644
--- a/grc/python/extract_docs.py
+++ b/grc/python/extract_docs.py
@@ -17,63 +17,31 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from Constants import DOCS_DIR
-from lxml import etree
-import os
import re
-DOXYGEN_NAME_XPATH = '/doxygen/compounddef/compoundname'
-DOXYGEN_BRIEFDESC_GR_XPATH = '/doxygen/compounddef/briefdescription'
-DOXYGEN_DETAILDESC_GR_XPATH = '/doxygen/compounddef/detaileddescription'
-
-GROUP_KEYS = "gr|trellis|noaa|vocoder|digital"
-
-def extract_txt(xml):
- """
- Recursivly pull the text out of an xml tree.
- @param xml the xml tree
- @return a string
- """
- text = (xml.text or '').replace('\n', '')
- tail = (xml.tail or '').replace('\n', '')
- if xml.tag == 'para': tail += '\n\n'
- if xml.tag == 'linebreak': text += '\n'
- if xml.tag == 'parametername': text += ': '
- return text + ''.join(
- map(lambda x: extract_txt(x), xml)
- ) + tail
-
def _extract(key):
"""
- Extract the documentation from the doxygen generated xml files.
- If multiple files match, combine the docs.
+ Extract the documentation from the python __doc__ strings.
+ If multiple modules match, combine the docs.
@param key the block key
@return a string with documentation
"""
- docs_dir = os.path.join(DOCS_DIR, 'xml')
- if not os.path.exists(docs_dir): return ''
#extract matches
- pattern = key.replace('_', '_*').replace('x', '\w')
- class_file_matcher = re.compile('^class%s\..*$'%pattern) #xml or xml.gz
- matches = filter(lambda f: class_file_matcher.match(f), os.listdir(docs_dir))
+ try:
+ module_name, constructor_name = key.split('_', 1)
+ module = __import__('gnuradio.'+module_name)
+ module = getattr(module, module_name)
+ except: return ''
+ pattern = constructor_name.replace('_', '_*').replace('x', '\w')
+ pattern_matcher = re.compile('^%s\w*$'%pattern)
+ matches = filter(lambda x: pattern_matcher.match(x), dir(module))
#combine all matches
doc_strs = list()
for match in matches:
try:
- xml_file = os.path.join(docs_dir, match)
- xml = etree.parse(xml_file)
- #extract descriptions
- comp_name = extract_txt(xml.xpath(DOXYGEN_NAME_XPATH)[0]).strip()
- comp_name = ' --- ' + comp_name + ' --- '
- if re.match(('(%s)_.*' % GROUP_KEYS), key):
- brief_desc = extract_txt(xml.xpath(DOXYGEN_BRIEFDESC_GR_XPATH)[0]).strip()
- detailed_desc = extract_txt(xml.xpath(DOXYGEN_DETAILDESC_GR_XPATH)[0]).strip()
- else:
- brief_desc = ''
- detailed_desc = ''
- #combine
- doc_strs.append('\n\n'.join([comp_name, brief_desc, detailed_desc]).strip())
- except IndexError: pass #bad format
+ title = ' --- ' + match + ' --- '
+ doc_strs.append('\n\n'.join([title, getattr(module, match).__doc__]).strip())
+ except: pass
return '\n\n'.join(doc_strs)
_docs_cache = dict()