Changeset 941
- Timestamp:
- Jun 18, 2012 9:53:39 AM (11 years ago)
- Location:
- specdomain/src/specdomain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/src/specdomain/sphinxcontrib/specdomain.py
r940 r941 19 19 from docutils.parsers.rst import directives #@UnusedImport 20 20 21 from sphinx import addnodes #@UnusedImport22 from sphinx.roles import XRefRole #@UnusedImport21 from sphinx import addnodes 22 from sphinx.roles import XRefRole 23 23 from sphinx.locale import l_, _ #@UnusedImport 24 from sphinx.directives import ObjectDescription #@UnusedImport24 from sphinx.directives import ObjectDescription 25 25 from sphinx.domains import Domain, ObjType, Index #@UnusedImport 26 26 from sphinx.util.compat import Directive #@UnusedImport 27 from sphinx.util.nodes import make_refnode #@UnusedImport28 from sphinx.util.docfields import Field, TypedField #@UnusedImport29 30 31 match_all = '.*'32 non_greedy_filler = match_all +'?'33 double_quote_string_match = '("'+non_greedy_filler+'")'34 word_match = '((?:[a-z_]\w*))'35 cdef_match = '(cdef)'36 extended_comment_flag = '\"\"\"'27 from sphinx.util.nodes import make_refnode 28 from sphinx.util.docfields import Field, TypedField 29 from sphinx.util.docstrings import prepare_docstring #@UnusedImport 30 31 match_all = r'.*' 32 non_greedy_filler = match_all + r'?' 33 double_quote_string_match = r'("' + non_greedy_filler + r'")' 34 word_match = r'((?:[a-z_]\w*))' 35 cdef_match = r'(cdef)' 36 extended_comment_flag = r'\"\"\"' 37 37 38 38 … … 41 41 ''', re.VERBOSE) 42 42 43 spec_func_sig_re = re.compile(word_match +'\('44 + '('+match_all+')'45 + '\)',43 spec_func_sig_re = re.compile(word_match + r'\(' 44 + r'(' + match_all + r')' 45 + r'\)', 46 46 re.IGNORECASE|re.DOTALL) 47 47 … … 52 52 spec_extended_comment_flag_sig_re = re.compile(extended_comment_flag, 53 53 re.IGNORECASE|re.DOTALL) 54 spec_extended_comment_start_sig_re = re.compile( '^'54 spec_extended_comment_start_sig_re = re.compile(r'^' 55 55 + non_greedy_filler 56 56 + extended_comment_flag, 57 57 re.IGNORECASE|re.DOTALL) 58 spec_extended_comment_block_sig_re = re.compile( '^'58 spec_extended_comment_block_sig_re = re.compile(r'^' 59 59 + non_greedy_filler 60 60 + extended_comment_flag 61 + '(' + non_greedy_filler +')'61 + r'(' + non_greedy_filler + r')' 62 62 + extended_comment_flag 63 63 + non_greedy_filler 64 + '$',64 + r'$', 65 65 re.IGNORECASE|re.DOTALL|re.MULTILINE) 66 66 … … 198 198 highlighted source code blocks. 199 199 ''' 200 results = self.parse_macro_file(sig) 201 indent = ' '*4 202 for item in results: 203 # FIXME: not desc_annotation but desc_content, but how to get it right? 204 # see <sphinx>/directives/__init__.py for an example 205 # It's a bit more complicated than this. 206 signode += addnodes.desc_annotation('\n', '\n') 207 for line in item.split('\n'): 208 signode += addnodes.desc_annotation(indent+line, indent+line) 200 extended_comments_list = self.parse_macro_file(sig) 201 for extended_comment in extended_comments_list: 202 linenumber = -1 # FIXME: 203 #for line in prepare_docstring(extended_comment, ignore=1): 204 # self.result.append(self.indent + line, sig, linenumber) # FIXME: 209 205 return sig 210 206 … … 215 211 :param str filename: name (with optional path) of SPEC macro file 216 212 (The path is relative to the ``.rst`` document.) 217 :returns [str]: list of ReST-formatted extended comment blocks from SPEC macro file.218 219 [future] parse more stuff as planned 213 :returns [str]: list of ReST-formatted extended comment blocks (docstrings) from SPEC macro file. 214 215 [future] parse more stuff as planned, this is very simplistic for now 220 216 """ 221 217 results = [] … … 224 220 225 221 buf = open(filename, 'r').read() 226 # TODO: loop until no matches, chopping away the buffer after each match 227 m = spec_extended_comment_block_sig_re.match(buf) 228 if m is not None: 229 rest = m.groups() 230 if len(rest) == 1: 231 results.append(rest[0]) 222 #n = len(buf) 223 for node in spec_extended_comment_block_sig_re.finditer(buf): 224 #g = node.group() 225 #gs = node.groups() 226 #s = node.start() 227 #e = node.end() 228 #t = buf[s:e] 229 results.append(node.groups()) # TODO: can we get line number also? 232 230 return results 233 231 -
specdomain/src/specdomain/test/starter.py
r937 r941 15 15 def force_rebuild_all(parent = '_build'): 16 16 ''' 17 Delete the *doctrees* subdirectory.17 Delete the pickle file. 18 18 19 19 :param str parent: path to *build* subdirectory (either ``build`` or ``_build``) 20 20 ''' 21 if os.path.exists(parent+'/doctrees'): 22 garbage_list = [ 23 parent+'/doctrees/environment.pickle', 24 #parent+'/doctrees/index.doctree', 25 #parent+'/doctrees/test_doc.doctree', 26 ] 27 for item in garbage_list: 28 if os.path.exists(item): 29 os.remove(item) 30 #os.rmdir(parent+'/doctrees') 21 pickle_file = parent+'/doctrees/environment.pickle' 22 if os.path.exists(pickle_file): 23 os.remove(pickle_file) 31 24 32 25
Note: See TracChangeset
for help on using the changeset viewer.