📄 doxproc.py
字号:
classes.append(entry) entries.append(entry) #~ Put them in a sensible order. entries.sort(lambda x,y: cmp(x['name'].lower(),y['name'].lower())) classes.sort(lambda x,y: cmp(x['name'].lower(),y['name'].lower())) #~ And generate the BoostBook for them. self._translate_index_(entries,target=self.section['index']) self._translate_index_(classes,target=self.section['classes']) return None #~ Translate a set of index entries in the BoostBook output. The output #~ is grouped into groups of the first letter of the entry names. def _translate_index_(self, entries, target=None, **kwargs ): i = 0 targetID = target.getAttribute('id') while i < len(entries): dividerKey = entries[i]['name'][0].upper() divider = target.appendChild(self._createNode('indexdiv',id=targetID+'.'+dividerKey)) divider.appendChild(self._createText('title',dividerKey)) while i < len(entries) and dividerKey == entries[i]['name'][0].upper(): iename = entries[i]['name'] ie = divider.appendChild(self._createNode('indexentry')) ie = ie.appendChild(self._createText('primaryie',iename)) while i < len(entries) and entries[i]['name'] == iename: ie.appendChild(self.boostbook.createTextNode(' (')) ie.appendChild(self._createText( 'link',entries[i]['compoundname'],linkend=entries[i]['id'])) ie.appendChild(self.boostbook.createTextNode(')')) i += 1 #~ Translate a <compounddef ...>...</compounddef>, #~ by retranslating with the "kind" of compounddef. def _translate_compounddef( self, node, target=None, **kwargs ): return self._translateNode(node,node.getAttribute('kind')) #~ Translate a <compounddef kind="namespace"...>...</compounddef>. For #~ namespaces we just collect the information for later use as there is no #~ currently namespaces are not included in the BoostBook format. In the future #~ it might be good to generate a namespace index. def _translate_compounddef_namespace( self, node, target=None, **kwargs ): namespace = { 'id' : node.getAttribute('id'), 'kind' : 'namespace', 'name' : self._getChildData('compoundname',root=node), 'brief' : self._getChildData('briefdescription',root=node), 'detailed' : self._getChildData('detaileddescription',root=node), 'parsed' : False } if self.symbols.has_key(namespace['name']): if not self.symbols[namespace['name']]['parsed']: self.symbols[namespace['name']]['parsed'] = True #~ for n in node.childNodes: #~ if hasattr(n,'getAttribute'): #~ self._translateNode(n,n.getAttribute('kind'),target=target,**kwargs) else: self.symbols[namespace['name']] = namespace #~ self._setID(namespace['id'],namespace['name']) return None #~ Translate a <compounddef kind="class"...>...</compounddef>, which #~ forwards to the kind=struct as they are the same. def _translate_compounddef_class( self, node, target=None, **kwargs ): return self._translate_compounddef_struct(node,tag='class',target=target,**kwargs) #~ Translate a <compounddef kind="struct"...>...</compounddef> into: #~ <header id="?" name="?"> #~ <struct name="?"> #~ ... #~ </struct> #~ </header> def _translate_compounddef_struct( self, node, tag='struct', target=None, **kwargs ): result = None includes = self._getChild('includes',root=node) if includes: ## Add the header into the output table. self._translate_compounddef_includes_(includes,includes,**kwargs) ## Compounds are the declared symbols, classes, types, etc. ## We add them to the symbol table, along with the partial DOM for them ## so that they can be organized into the output later. compoundname = self._getChildData('compoundname',root=node) compoundname = self._cppName(compoundname) self._setID(node.getAttribute('id'),compoundname['compoundname']) struct = self._createNode(tag,name=compoundname['name'].split('::')[-1]) self.symbols[compoundname['compoundname']] = { 'header' : includes.firstChild.data, 'namespace' : compoundname['namespace'], 'id' : node.getAttribute('id'), 'kind' : tag, 'name' : compoundname['name'], 'dom' : struct } ## Add the children which will be the members of the struct. for n in node.childNodes: self._translateNode(n,target=struct,scope=compoundname['compoundname']) result = struct return result #~ Translate a <compounddef ...><includes ...>...</includes></compounddef>, def _translate_compounddef_includes_( self, node, target=None, **kwargs ): name = node.firstChild.data if not self.symbols.has_key(name): self._setID(node.getAttribute('refid'),name) self.symbols[name] = { 'kind' : 'header', 'id' : node.getAttribute('refid'), 'dom' : self._createNode('header', id=node.getAttribute('refid'), name=name) } return None #~ Translate a <basecompoundref...>...</basecompoundref> into: #~ <inherit access="?"> #~ ... #~ </inherit> def _translate_basecompoundref( self, ref, target=None, **kwargs ): inherit = target.appendChild(self._createNode('inherit', access=ref.getAttribute('prot'))) self._translateChildren(ref,target=inherit) return #~ Translate: #~ <templateparamlist> #~ <param> #~ <type>...</type> #~ <declname>...</declname> #~ <defname>...</defname> #~ <defval>...</defval> #~ </param> #~ ... #~ </templateparamlist> #~ Into: #~ <template> #~ <template-type-parameter name="?" /> #~ <template-nontype-parameter name="?"> #~ <type>?</type> #~ <default>?</default> #~ </template-nontype-parameter> #~ </template> def _translate_templateparamlist( self, templateparamlist, target=None, **kwargs ): template = target.appendChild(self._createNode('template')) for param in templateparamlist.childNodes: if param.nodeName == 'param': type = self._getChildData('type',root=param) defval = self._getChild('defval',root=param) paramKind = None if type in ('class','typename'): paramKind = 'template-type-parameter' else: paramKind = 'template-nontype-parameter' templateParam = template.appendChild( self._createNode(paramKind, name=self._getChildData('declname',root=param))) if paramKind == 'template-nontype-parameter': template_type = templateParam.appendChild(self._createNode('type')) self._translate_type( self._getChild('type',root=param),target=template_type) if defval: value = self._getChildData('ref',root=defval.firstChild) if not value: value = self._getData(defval) templateParam.appendChild(self._createText('default',value)) return template #~ Translate: #~ <briefdescription>...</briefdescription> #~ Into: #~ <purpose>...</purpose> def _translate_briefdescription( self, brief, target=None, **kwargs ): self._translateDescription(brief,target=target,**kwargs) return self._translateDescription(brief,target=target,tag='purpose',**kwargs) #~ Translate: #~ <detaileddescription>...</detaileddescription> #~ Into: #~ <description>...</description> def _translate_detaileddescription( self, detailed, target=None, **kwargs ): return self._translateDescription(detailed,target=target,**kwargs) #~ Translate: #~ <sectiondef kind="?">...</sectiondef> #~ With kind specific translation. def _translate_sectiondef( self, sectiondef, target=None, **kwargs ): self._translateNode(sectiondef,sectiondef.getAttribute('kind'),target=target,**kwargs) #~ Translate non-function sections. def _translate_sectiondef_x_( self, sectiondef, target=None, **kwargs ): for n in sectiondef.childNodes: if hasattr(n,'getAttribute'): self._translateNode(n,n.getAttribute('kind'),target=target,**kwargs) return None #~ Translate: #~ <sectiondef kind="public-type">...</sectiondef> def _translate_sectiondef_public_type( self, sectiondef, target=None, **kwargs ): return self._translate_sectiondef_x_(sectiondef,target=target,**kwargs) #~ Translate: #~ <sectiondef kind="public-sttrib">...</sectiondef> def _translate_sectiondef_public_attrib( self, sectiondef, target=None, **kwargs): return self._translate_sectiondef_x_(sectiondef,target=target,**kwargs) #~ Translate: #~ <sectiondef kind="?-func">...</sectiondef> #~ All the various function group translations end up here for which #~ they are translated into: #~ <method-group name="?"> #~ ... #~ </method-group> def _translate_sectiondef_func_( self, sectiondef, name='functions', target=None, **kwargs ): members = target.appendChild(self._createNode('method-group',name=name)) for n in sectiondef.childNodes: if hasattr(n,'getAttribute'): self._translateNode(n,n.getAttribute('kind'),target=members,**kwargs) return members #~ Translate: #~ <sectiondef kind="public-func">...</sectiondef> def _translate_sectiondef_public_func( self, sectiondef, target=None, **kwargs ): return self._translate_sectiondef_func_(sectiondef, name='public member functions',target=target,**kwargs) #~ Translate: #~ <sectiondef kind="public-static-func">...</sectiondef> def _translate_sectiondef_public_static_func( self, sectiondef, target=None, **kwargs): return self._translate_sectiondef_func_(sectiondef, name='public static functions',target=target,**kwargs) #~ Translate: #~ <sectiondef kind="protected-func">...</sectiondef> def _translate_sectiondef_protected_func( self, sectiondef, target=None, **kwargs ): return self._translate_sectiondef_func_(sectiondef, name='protected member functions',target=target,**kwargs) #~ Translate: #~ <sectiondef kind="private-static-func">...</sectiondef> def _translate_sectiondef_private_static_func( self, sectiondef, target=None, **kwargs): return self._translate_sectiondef_func_(sectiondef, name='private static functions',target=target,**kwargs) #~ Translate: #~ <sectiondef kind="public-func">...</sectiondef> def _translate_sectiondef_private_func( self, sectiondef, target=None, **kwargs ): return self._translate_sectiondef_func_(sectiondef, name='private member functions',target=target,**kwargs) #~ Translate: #~ <sectiondef kind="user-defined"><header>...</header>...</sectiondef> def _translate_sectiondef_user_defined( self, sectiondef, target=None, **kwargs ): return self._translate_sectiondef_func_(sectiondef, name=self._getChildData('header', root=sectiondef),target=target,**kwargs) #~ Translate: #~ <memberdef kind="typedef" id="?"> #~ <name>...</name> #~ </memberdef> #~ To: #~ <typedef id="?" name="?"> #~ <type>...</type> #~ </typedef> def _translate_memberdef_typedef( self, memberdef, target=None, scope=None, **kwargs ): self._setID(memberdef.getAttribute('id'), scope+'::'+self._getChildData('name',root=memberdef)) typedef = target.appendChild(self._createNode('typedef', id=memberdef.getAttribute('id'), name=self._getChildData('name',root=memberdef))) typedef_type = typedef.appendChild(self._createNode('type')) self._translate_type(self._getChild('type',root=memberdef),target=typedef_type) return typedef #~ Translate: #~ <memberdef kind="function" id="?" const="?" static="?" explicit="?" inline="?"> #~ <name>...</name> #~ </memberdef> #~ To: #~ <method name="?" cv="?" specifiers="?"> #~ ... #~ </method> def _translate_memberdef_function( self, memberdef, target=None, scope=None, **kwargs ): name = self._getChildData('name',root=memberdef) self._setID(memberdef.getAttribute('id'),scope+'::'+name) ## Check if we have some specific kind of method. if name == scope.split('::')[-1]: kind = 'constructor' target = target.parentNode elif name == '~'+scope.split('::')[-1]: kind = 'destructor'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -