[Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML Part.py,1.36,1.37
Stefan Seefeld stefan at synopsis.fresco.orgSat Nov 15 19:53:46 UTC 2003
- Previous message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML/Parts - New directory
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML/Parts Detail.py,NONE,1.1 Heading.py,NONE,1.1 Inheritance.py,NONE,1.1 Summary.py,NONE,1.1 __init__.py,NONE,1.1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML
In directory frida:/tmp/cvs-serv5049/Synopsis/Formatters/HTML
Modified Files:
Part.py
Log Message:
refactor parts
Index: Part.py
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/Part.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -p -d -r1.36 -r1.37
--- Part.py 15 Nov 2003 19:01:53 -0000 1.36
+++ Part.py 15 Nov 2003 19:53:44 -0000 1.37
@@ -18,7 +18,6 @@ and are defined in the FormatStrategy mo
from Synopsis import AST, Type, Util
import Tags, core, FormatStrategy
-from core import config, DeclStyle
from Tags import *
import types, os
@@ -269,271 +268,3 @@ class Part(Type.Visitor, AST.Visitor):
"Abstract method to end the output, eg close the table"
pass
-
-class Heading(Part):
- """Heading page part. Displays a header for the page -- its strategies are
- only passed the object that the page is for; ie a Class or Module"""
-
- def register(self, page):
-
- Part.register(self, page)
- self._init_formatters('heading_formatters', 'heading')
-
- def _init_default_formatters(self):
-
- self.addFormatter(FormatStrategy.Heading)
- self.addFormatter(FormatStrategy.ClassHierarchyGraph)
- self.addFormatter(FormatStrategy.DetailCommenter)
-
- def writeSectionItem(self, text):
- """Writes text and follows with a horizontal rule"""
-
- self.write(text + '\n<hr>\n')
-
- def process(self, decl):
- """Process this Part by formatting only the given decl"""
-
- decl.accept(self)
-
-class Summary(Part):
- """Formatting summary visitor. This formatter displays a summary for each
- declaration, with links to the details if there is one. All of this is
- controlled by the ASTFormatters."""
-
- def register(self, page):
-
- Part.register(self, page)
- self.__link_detail = 0
- self._init_formatters('summary_formatters', 'summary')
-
- def _init_default_formatters(self):
-
- self.addFormatter( FormatStrategy.SummaryAST )
- self.addFormatter( FormatStrategy.SummaryCommenter )
-
- def set_link_detail(self, boolean):
- """Sets link_detail flag to given value.
- @see label()"""
-
- self.__link_detail = boolean
- config.link_detail = boolean
-
- def label(self, ref, label=None):
- """Override to check link_detail flag. If it's set, returns a reference
- instead - which will be to the detailed info"""
-
- if label is None: label = ref
- if self.__link_detail:
- # Insert a reference instead
- return span('name',self.reference(ref, Util.ccolonName(label, self.scope())))
- return Part.label(self, ref, label)
-
- def writeSectionStart(self, heading):
- """Starts a table entity. The heading is placed in a row in a td with
- the class 'heading'."""
-
- self.write('<table width="100%%" summary="%s">\n'%heading)
- self.write('<col><col width="100%%">')
- self.write('<tr><td class="heading" colspan="2">' + heading + '</td></tr>\n')
-
- def writeSectionEnd(self, heading):
- """Closes the table entity and adds a break."""
-
- self.write('</table>\n<br>\n')
-
- def writeSectionItem(self, text):
- """Adds a table row"""
-
- if text[:22] == '<td class="summ-start"':
- # text provided its own TD element
- self.write('<tr>' + text + '</td></tr>\n')
- else:
- self.write('<tr><td class="summ-start">' + text + '</td></tr>\n')
-
- def process(self, decl):
- "Print out the summaries from the given decl"
-
- decl_style = config.decl_style
- SUMMARY = DeclStyle.SUMMARY
- config.link_detail = 0
-
- config.sorter.set_scope(decl)
- config.sorter.sort_section_names()
-
- self.write_start()
- for section in config.sorter.sections():
- # Write a header for this section
- if section[-1] == 's': heading = section+'es Summary:'
- else: heading = section+'s Summary:'
- self.writeSectionStart(heading)
- # Iterate through the children in this section
- for child in config.sorter.children(section):
- # Check if need to add to detail list
- if decl_style[child] != SUMMARY:
- # Setup the linking stuff
- self.set_link_detail(1)
- child.accept(self)
- self.set_link_detail(0)
- else:
- # Just do it
- child.accept(self)
- # Finish off this section
- self.writeSectionEnd(heading)
- self.write_end()
-
-class Detail(Part):
-
- def register(self, page):
-
- Part.register(self, page)
- self._init_formatters('detail_formatters', 'detail')
-
- def _init_default_formatters(self):
-
- self.addFormatter( FormatStrategy.DetailAST )
- #self.addFormatter( ClassHierarchySimple )
- self.addFormatter( FormatStrategy.DetailCommenter )
-
- def writeSectionStart(self, heading):
- """Creates a table with one row. The row has a td of class 'heading'
- containing the heading string"""
-
- self.write('<table width="100%%" summary="%s">\n'%heading)
- self.write('<tr><td colspan="2" class="heading">' + heading + '</td></tr>\n')
- self.write('</table>')
-
- def writeSectionItem(self, text):
- """Writes text and follows with a horizontal rule"""
-
- self.write(text + '\n<hr>\n')
-
- def process(self, decl):
- "Print out the details for the children of the given decl"
-
- decl_style = config.decl_style
- SUMMARY = DeclStyle.SUMMARY
-
- config.sorter.set_scope(decl)
- config.sorter.sort_section_names()
-
- # Iterate through the sections with details
- self.write_start()
- for section in config.sorter.sections():
- # Write a heading
- heading = section+' Details:'
- started = 0 # Lazy section start incase no details for this section
- # Iterate through the children in this section
- for child in config.sorter.children(section):
- # Check if need to add to detail list
- if decl_style[child] == SUMMARY:
- continue
- # Check section heading
- if not started:
- started = 1
- self.writeSectionStart(heading)
- child.accept(self)
- # Finish the section
- if started: self.writeSectionEnd(heading)
- self.write_end()
-
-class Inheritance(Part):
-
- def register(self, page):
-
- Part.register(self, page)
- self._init_formatters('inheritance_formatters', 'inheritance')
- self.__start_list = 0
-
- def _init_default_formatters(self):
-
- self.addFormatter( FormatStrategy.Inheritance )
-
- def process(self, decl):
- "Walk the hierarchy to find inherited members to print."
-
- if not isinstance(decl, AST.Class): return
- self.write_start()
- names = decl.declarations()
- names = map(self._short_name, names)
- self._process_superclasses(decl, names)
- self.write_end()
-
- def _process_class(self, clas, names):
- "Prints info for the given class, and calls _process_superclasses after"
-
- config.sorter.set_scope(clas)
- config.sorter.sort_section_names()
- child_names = []
-
- # Iterate through the sections
- for section in config.sorter.sections():
- # Write a heading
- heading = section+'s Inherited from '+ Util.ccolonName(clas.name(), self.scope())
- started = 0 # Lazy section start incase no details for this section
- # Iterate through the children in this section
- for child in config.sorter.children(section):
- child_name = self._short_name(child)
- if child_name in names:
- continue
- # FIXME: This doesn't account for the inheritance type
- # (private etc)
- if child.accessibility() == AST.PRIVATE:
- continue
- # Don't include constructors and destructors!
- if isinstance(child, AST.Function) and child.language() == 'C++' and len(child.realname())>1:
- if child.realname()[-1] == child.realname()[-2]: continue
- elif child.realname()[-1] == "~"+child.realname()[-2]: continue
- # FIXME: skip overriden declarations
- child_names.append(child_name)
- # Check section heading
- if not started:
- started = 1
- self.writeSectionStart(heading)
- child.accept(self)
- # Finish the section
- if started: self.writeSectionEnd(heading)
-
- self._process_superclasses(clas, names + child_names)
-
- def _short_name(self, decl):
- if isinstance(decl, AST.Function):
- return decl.realname()[-1]
- return decl.name()[-1]
-
- def _process_superclasses(self, clas, names):
- """Iterates through the superclasses of clas and calls _process_clas for
- each"""
-
- for inheritance in clas.parents():
- parent = inheritance.parent()
- if isinstance(parent, Type.Declared):
- parent = parent.declaration()
- if isinstance(parent, AST.Class):
- self._process_class(parent, names)
- continue
- #print "Ignoring", parent.__class__.__name__, "parent of", clas.name()
- pass #ignore
-
- def writeSectionStart(self, heading):
- """Creates a table with one row. The row has a td of class 'heading'
- containing the heading string"""
-
- self.write('<table width="100%%" summary="%s">\n'%heading)
- self.write('<tr><td colspan="2" class="heading">' + heading + '</td></tr>\n')
- self.write('<tr><td class="inherited">')
- self.__start_list = 1
-
- def writeSectionItem(self, text):
- """Adds a table row"""
-
- if self.__start_list:
- self.write(text)
- self.__start_list = 0
- else:
- self.write(',\n'+text)
-
- def writeSectionEnd(self, heading):
- """Closes the table entity and adds a break."""
- self.write('</td></tr></table>\n<br>\n')
-
-
- Previous message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML/Parts - New directory
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML/Parts Detail.py,NONE,1.1 Heading.py,NONE,1.1 Inheritance.py,NONE,1.1 Summary.py,NONE,1.1 __init__.py,NONE,1.1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list