Changeset 994
- Timestamp:
- Jul 6, 2012 2:15:32 PM (11 years ago)
- Location:
- specdomain/trunk/src/specdomain
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/trunk/src/specdomain/sphinxcontrib/specdomain.py
r989 r994 130 130 #self.add_directive_header(sig) 131 131 132 # TODO: provide links from each to highlighted source code blocks (like Python documenters).133 # This works for now.134 132 self.add_line(u'', '<autodoc>') 135 133 self.add_line(u'.. index:: SPEC macro file; %s' % macrofile, '<autodoc>') 136 134 self.add_line(u'.. index:: !%s' % os.path.split(macrofile)[1], '<autodoc>') 137 135 self.add_line(u'', '<autodoc>') 136 self.add_line(u'', '<autodoc>') 137 title = 'SPEC Macro File: %s' % macrofile 138 self.add_line('@'*len(title), '<autodoc>') 139 self.add_line(title, '<autodoc>') 140 self.add_line('@'*len(title), '<autodoc>') 141 self.add_line(u'', '<autodoc>') 142 # TODO: provide links from each to highlighted source code blocks (like Python documenters). 143 # This works for now. 138 144 line = 'source code: :download:`%s <%s>`' % (macrofile, macrofile) 139 145 self.add_line(line, macrofile) … … 165 171 'given for autospecmacro %s' % self.fullname) 166 172 return ret 173 174 175 class SpecDirDocumenter(Documenter): 176 objtype = 'specdir' 177 member_order = 50 178 priority = 0 179 #: true if the generated content may contain titles 180 titles_allowed = True 181 option_spec = { 182 'include_subdirs': bool_option, 183 } 184 185 @classmethod 186 def can_document_member(cls, member, membername, isattr, parent): 187 return membername in ('SpecDirDocumenter', ) 188 189 def generate(self, *args, **kw): 190 """ 191 Look at the named directory and 192 Generate reST for the object given by *self.name*, and possibly for 193 its members. 194 """ 195 # now, parse the .mac files in the SPEC directory 196 specdir = self.name 197 # self.add_line(u'', '<autodoc>') 198 # self.add_line(u'directory:\n ``%s``' % specdir, '<autodoc>') 199 if os.path.exists(specdir): 200 for f in sorted(os.listdir(specdir)): 201 filename = os.path.join(specdir, f) 202 if os.path.isfile(filename) and filename.endswith('.mac'): 203 # TODO: support a user choice for pattern match to the file name (glob v. re) 204 # TODO: support the option to include subdirectories (include_subdirs) 205 # TODO: do not add the same SPEC macro file more than once 206 self.add_line(u'', '<autodoc>') 207 self.add_line(u'.. autospecmacro:: %s' % filename, '<autodoc>') 208 # TODO: any options? 209 self.add_line(u'', '<autodoc>') 210 # TODO: suppress delimiter after last file 211 self.add_line(u'-'*15, '<autodoc>') # delimiter between files 212 else: 213 self.add_line(u'', '<autodoc>') 214 self.add_line(u'Could not find directory: ``%s``' % specdir, '<autodoc>') 215 167 216 168 217 … … 355 404 app.add_domain(SpecDomain) 356 405 app.add_autodocumenter(SpecMacroDocumenter) 406 app.add_autodocumenter(SpecDirDocumenter) 357 407 app.add_config_value('autospecmacrodir_process_subdirs', True, True) -
specdomain/trunk/src/specdomain/sphinxcontrib/specmacrofileparser.py
r993 r994 381 381 macros = [] # def, cdef, and rdef macros 382 382 functions = [] # def and rdef function macros 383 #title = 'Extended Comments'384 #s = ['', title, '='*len(title), ]385 383 s = [] 386 384 for r in self.findings: 387 385 if r['objtype'] == 'extended comment': 386 # TODO: apply rules to suppress reporting under certain circumstances 388 387 s.append( '' ) 389 388 s.append( '.. %s %s %d %d' % (self.filename, … … 394 393 s.append(r['text']) 395 394 elif r['objtype'] in ('def', 'rdef', 'cdef', ): 395 # TODO: apply rules to suppress reporting under certain circumstances 396 396 macros.append(r) 397 397 s.append( '' ) … … 402 402 r['end_line']) ) 403 403 s.append( '' ) 404 # TODO: make this next be part of the signature display (in specdomain) 404 405 s.append( '.. rubric:: %s macro declaration' % r['objtype'] ) 405 406 s.append( '' ) 406 #s.append( '.. spec:%s:: %s %s' % ( r['objtype'], r['name'], r['args'],) )407 407 s.append( '.. spec:%s:: %s' % ( r['objtype'], r['name'],) ) 408 408 elif r['objtype'] in ('function def', 'function rdef',): 409 # FIXME: not getting here, such as for kohzuE_cmd()409 # TODO: apply rules to suppress reporting under certain circumstances 410 410 functions.append(r) 411 411 s.append( '' ) … … 420 420 s.append( '.. spec:%s:: %s(%s)' % ( r['objtype'], r['name'], r['args']) ) 421 421 elif r['objtype'] in ('local', 'global', 'constant'): 422 # TODO: apply rules to suppress reporting under certain circumstances 422 423 del r['text'] 423 424 declarations.append(r) 424 425 425 s += report_table('Variable Declarations ', declarations, ('start_line', 'objtype', 'name', 'line',))426 s += report_table('Macro Declarations ', macros, ('start_line', 'name', 'line',))427 s += report_table('Function Macro Declarations ', functions)426 s += report_table('Variable Declarations (%s)' % self.filename, declarations, ('start_line', 'objtype', 'name', 'line',)) 427 s += report_table('Macro Declarations (%s)' % self.filename, macros, ('start_line', 'name', 'line',)) 428 s += report_table('Function Macro Declarations (%s)' % self.filename, functions) 428 429 #s += report_table('Findings from .mac File', self.findings, ('start_line', 'objtype', 'line',)) 429 430 -
specdomain/trunk/src/specdomain/test/ccdscan_4.0.mac.rst
r983 r994 1 1 .. $Id$ 2 2 3 =============================================================4 SPEC macro source file: ``../macros/ccdscan_4.0.mac``5 =============================================================6 7 3 .. autospecmacro:: ../macros/ccdscan_4.0.mac -
specdomain/trunk/src/specdomain/test/cdef-examples.mac.rst
r983 r994 1 1 .. $Id$ 2 2 3 =============================================================4 SPEC macro source file: ``../macros/cdef-examples.mac``5 =============================================================6 7 3 .. autospecmacro:: ../macros/cdef-examples.mac -
specdomain/trunk/src/specdomain/test/shutter.mac.rst
r983 r994 1 1 .. $Id$ 2 3 ====================================================4 SPEC macro source file: ``../macros/shutter.mac``5 ====================================================6 2 7 3 .. caution:: This file is as-received. -
specdomain/trunk/src/specdomain/test/test-battery.mac.rst
r983 r994 1 1 .. $Id$ 2 2 3 ========================================================4 SPEC macro source file: ``../macros/test-battery.mac``5 ========================================================6 7 3 .. autospecmacro:: ../macros/test-battery.mac -
specdomain/trunk/src/specdomain/test/test_doc.rst
r989 r994 96 96 constant declaration: 97 97 98 .. spec: local:: TWO_PI98 .. spec:constant:: TWO_PI 99 99 100 100 ``TWO_PI`` is the ratio of a circle's circumference to its diameter. … … 150 150 151 151 *.mac 152 test_autospecdir -
specdomain/trunk/src/specdomain/test/usaxs_load.mac.rst
r985 r994 1 1 .. $Id$ 2 2 3 =============================================================4 SPEC macro source file: ``../macros/usaxs_load.mac``5 =============================================================6 7 3 .. autospecmacro:: ../macros/usaxs_load.mac -
specdomain/trunk/src/specdomain/test/usaxs_uascan.mac.rst
r985 r994 1 1 .. $Id$ 2 2 3 =============================================================4 SPEC macro source file: ``../macros/usaxs_uascan.mac``5 =============================================================6 7 3 .. autospecmacro:: ../macros/usaxs_uascan.mac
Note: See TracChangeset
for help on using the changeset viewer.