Ignore:
Timestamp:
Jun 18, 2012 6:19:12 PM (10 years ago)
Author:
jemian
Message:

refs #8, apply ANL's short-form license, starting to understand how to get content added, try additional test case SPEC macro file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • specdomain/src/specdomain/sphinxcontrib/specdomain.py

    r941 r942  
    44    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    55
    6     SPEC domain.
    7 
    8     :copyright: Copyright 2012 by Pete Jemian
    9     :license: BSD, see LICENSE for details.
     6    :synopsis: SPEC domain for Sphinx
     7   
     8    Automatically insert ReST-formatted extended comments
     9    from SPEC files for macro definitions and variable declarations into
     10    the Sphinx doctree, thus avoiding duplication between docstrings and documentation
     11    for those who like elaborate docstrings.
     12
     13    :copyright: Copyright 2012 by BCDA, Advanced Photon Source, Argonne National Laboratory
     14    :license: ANL Open Source License, see LICENSE for details.
    1015"""
    1116
     
    2530from sphinx.domains import Domain, ObjType, Index       #@UnusedImport
    2631from sphinx.util.compat import Directive                #@UnusedImport
    27 from sphinx.util.nodes import make_refnode
     32from sphinx.util.nodes import make_refnode, nested_parse_with_titles
    2833from sphinx.util.docfields import Field, TypedField
    2934from sphinx.util.docstrings import prepare_docstring    #@UnusedImport
     35
     36from docutils.statemachine import ViewList, string2lines
     37import sphinx.util.nodes
     38
    3039
    3140match_all                   = r'.*'
     
    199208        '''
    200209        extended_comments_list = self.parse_macro_file(sig)
     210        view = ViewList([u'TODO: recognize the ReST formatting in the following extended comment and it needs to be cleaned up'])
     211        node = nodes.paragraph()
     212        node.document = self.state.document
     213        self.state.nested_parse(view, 0, signode)
     214        # TODO: recognize the ReST formatting in the following extended comment and it needs to be cleaned up
    201215        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:
     216            for line in string2lines(extended_comment):
     217                view = ViewList([line])
     218                nested_parse_with_titles(self.state, view, signode)
    205219        return sig
    206220   
     
    227241            #e = node.end()
    228242            #t = buf[s:e]
    229             results.append(node.groups())            # TODO: can we get line number also?
     243            results.append(node.groups()[0])            # TODO: can we get line number also?
    230244        return results
    231245
Note: See TracChangeset for help on using the changeset viewer.