- Timestamp:
- 10/22/2008 01:27:48 PM (3 months ago)
- Location:
- vendor/epydoc/current/src/epydoc
- Files:
-
- 4 modified
-
cli.py (modified) (4 diffs)
-
docintrospecter.py (modified) (3 diffs)
-
docwriter/latex.py (modified) (39 diffs)
-
docwriter/latex_sty.py (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/epydoc/current/src/epydoc/cli.py
r2476 r2751 5 5 # URL: <http://epydoc.sf.net> 6 6 # 7 # $Id: cli.py 180 1 2008-02-27 00:20:24Z edloper $7 # $Id: cli.py 1807 2008-03-04 02:32:58Z edloper $ 8 8 9 9 """ … … 1057 1057 log.info('%r pdfdriver selected' % options.pdfdriver) 1058 1058 1059 from epydoc.docwriter.latex import LatexWriter 1059 from epydoc.docwriter.latex import LatexWriter, show_latex_warnings 1060 1060 latex_writer = LatexWriter(docindex, **options.__dict__) 1061 latex_writer.write(latex_target) 1061 try: 1062 latex_writer.write(latex_target) 1063 except IOError, e: 1064 log.error(e) 1065 log.end_progress() 1066 log.start_progress() 1067 log.end_progress() 1068 return 1062 1069 log.end_progress() 1063 1070 … … 1120 1127 # changed what page some things are on. 1121 1128 running = latex_command 1122 if _RERUN_LATEX_RE. match(out):1129 if _RERUN_LATEX_RE.search(out): 1123 1130 log.progress(step/steps, '%s (Third pass)' % LaTeX) 1124 1131 out, err = run_subprocess('%s api.tex' % latex_command) … … 1126 1133 # A fourth path should (almost?) never be necessary. 1127 1134 running = latex_command 1128 if _RERUN_LATEX_RE. match(out):1135 if _RERUN_LATEX_RE.search(out): 1129 1136 log.progress(step/steps, '%s (Fourth pass)' % LaTeX) 1130 run_subprocess('%s api.tex' % latex_command)1137 out, err = run_subprocess('%s api.tex' % latex_command) 1131 1138 step += 1 1139 1140 # Show the output, if verbosity is high: 1141 if options.verbosity > 2 or epydoc.DEBUG: 1142 show_latex_warnings(out) 1132 1143 1133 1144 # If requested, convert to postscript. -
vendor/epydoc/current/src/epydoc/docintrospecter.py
r2476 r2751 5 5 # URL: <http://epydoc.sf.net> 6 6 # 7 # $Id: docintrospecter.py 1 722 2008-02-15 01:11:18Z edloper $7 # $Id: docintrospecter.py 1810 2008-03-31 03:22:51Z edloper $ 8 8 9 9 """ … … 268 268 # value if it's defined in this module. 269 269 container = get_containing_module(child) 270 if ((container is not None and 271 container == name_without_primes) or 272 (public_names is not None and 273 child_name in public_names)): 270 if (((container is not None and 271 container == name_without_primes) or 272 (public_names is not None and 273 child_name in public_names)) 274 and not inspect.ismodule(child)): 274 275 # Local variable. 275 276 child_val_doc = introspect_docs(child, context=module_doc, … … 280 281 container=module_doc, 281 282 docs_extracted_by='introspecter') 282 elif container is None or module_doc.canonical_name is UNKNOWN: 283 elif ((container is None or module_doc.canonical_name is UNKNOWN) 284 and not inspect.ismodule(child)): 283 285 284 286 # Don't introspect stuff "from __future__" -
vendor/epydoc/current/src/epydoc/docwriter/latex.py
r2476 r2751 4 4 # 5 5 # Created [01/30/01 05:18 PM] 6 # $Id: latex.py 1 799 2008-02-27 00:01:42Z edloper $6 # $Id: latex.py 1809 2008-03-05 18:40:49Z edloper $ 7 7 # 8 8 … … 46 46 # Process keyword arguments 47 47 self._show_private = kwargs.get('show_private', 0) 48 self._prj_name = kwargs.get('prj_name', None) or 'API Documentation'48 self._prj_name = kwargs.get('prj_name', None) 49 49 self._show_crossrefs = kwargs.get('crossref', 1) 50 50 self._index = kwargs.get('index', 1) … … 125 125 filename = '%s-module.tex' % val_doc.canonical_name 126 126 self._write(self.write_module, directory, filename, val_doc) 127 elif (isinstance(val_doc, ClassDoc) and 128 self._list_classes_separately): 127 elif isinstance(val_doc, ClassDoc): 129 128 filename = '%s-class.tex' % val_doc.canonical_name 130 129 self._write(self.write_class, directory, filename, val_doc) … … 205 204 @rtype: C{int} 206 205 """ 207 n = 1 208 for doc in self.valdocs: 209 if isinstance(doc, ModuleDoc): n += 1 210 if isinstance(doc, ClassDoc) and self._list_classes_separately: 211 n += 1 212 return n 206 return 1 + len([doc for doc in self.valdocs 207 if isinstance(doc, (ClassDoc, ModuleDoc))]) 213 208 214 209 def _mkdir(self, directory): … … 230 225 self.write_preamble(out) 231 226 out('\n\\begin{document}\n\n') 232 self.write_start_of(out, 'Header')227 out(self.start_of('Header')) 233 228 234 229 # Write the title. 235 self.write_start_of(out, 'Title') 236 out('\\title{%s}\n' % plaintext_to_latex(self._prj_name, 1)) 230 out(self.start_of('Title')) 231 out('\\title{%s}\n' % plaintext_to_latex( 232 self._prj_name or 'API Documentation', 1)) 237 233 out('\\author{API Documentation}\n') 238 234 out('\\maketitle\n') 239 235 240 236 # Add a table of contents. 241 self.write_start_of(out, 'Table of Contents')237 out(self.start_of('Table of Contents')) 242 238 out('\\addtolength{\\parskip}{-1ex}\n') 243 239 out('\\tableofcontents\n') … … 245 241 246 242 # Include documentation files. 247 self.write_start_of(out, 'Includes')243 out(self.start_of('Includes')) 248 244 for val_doc in self.valdocs: 249 245 if isinstance(val_doc, ModuleDoc): … … 259 255 # Add the index, if requested. 260 256 if self._index: 261 self.write_start_of(out, 'Index')257 out(self.start_of('Index')) 262 258 out('\\printindex\n\n') 263 259 264 260 # Add the footer. 265 self.write_start_of(out, 'Footer')261 out(self.start_of('Footer')) 266 262 out('\\end{document}\n\n') 267 263 … … 308 304 def write_module(self, out, doc): 309 305 self.write_header(out, doc) 310 self.write_start_of(out, 'Module Description')306 out(self.start_of('Section Heading', doc)) 311 307 312 308 # Add this module to the index. 313 out( ' ' +self.indexterm(doc, 'start'))309 out(self.indexterm(doc, 'start')) 314 310 315 311 # Add a section marker. … … 320 316 # Add the module's description. 321 317 if doc.descr not in (None, UNKNOWN): 322 out(' '*4 + '\\begin{EpydocModuleDescription}%\n') 318 out(self.start_of('Description', doc)) 319 out('\\begin{EpydocModuleDescription}%\n') 323 320 out(self.docstring_to_latex(doc.descr, doc, 4)) 324 out(' '*4 + '\\end{EpydocModuleDescription}\n')321 out('\\end{EpydocModuleDescription}\n') 325 322 326 323 # Add version, author, warnings, requirements, notes, etc. 327 self.write_standard_fields(out, doc)324 out(self.metadata(doc)) 328 325 329 326 # If it's a package, list the sub-modules. … … 343 340 classes = doc.select_variables(imported=False, value_type='class', 344 341 public=self._public_filter) 345 for var_doc in classes: 346 self.write_class(out, var_doc.value) 342 if classes: 343 out(self.start_of('Classes', doc)) 344 for var_doc in classes: 345 # don't use \include -- can't be nested. 346 out('\\input{%s-class}\n' % var_doc.value.canonical_name) 347 347 348 348 # Mark the end of the module (for the index) 349 out(' ' + self.indexterm(doc, 'end')) 349 out(self.start_of('Footer', doc)) 350 out(self.indexterm(doc, 'end')) 350 351 351 352 def render_graph(self, graph): … … 354 355 return graph.to_latex(self._directory) or '' 355 356 356 def write_class(self, out, doc, short_name=None): 357 if short_name is None: short_name = doc.canonical_name[-1] 358 357 def write_class(self, out, doc): 358 self.write_header(out, doc) 359 out(self.start_of('Section Heading', doc)) 360 361 # Add this class to the index. 362 out(self.indexterm(doc, 'start')) 363 364 # Decide on our short (contextualized) name. 359 365 if self._list_classes_separately: 360 self.write_header(out, doc) 361 self.write_start_of(out, 'Class Description') 362 363 # Add this class to the index. 364 out(' ' + self.indexterm(doc, 'start')) 365 366 # Add a section marker. 366 short_name = doc.canonical_name 367 if doc.defining_module not in (None, UNKNOWN): 368 short_name = doc.canonical_name.contextualize( 369 doc.defining_module.canonical_name) 370 else: 371 short_name = doc.canonical_name[-1] 372 373 # Decidie on our initial section level. 367 374 if self._list_classes_separately: 368 375 seclevel = 0 369 out(self.section('%s %s' % (self.doc_kind(doc),370 _dotted(doc.canonical_name)),371 seclevel, ref=doc))372 376 else: 373 377 seclevel = 1 374 out(self.section('%s %s' % (self.doc_kind(doc), 375 _dotted(short_name)), 376 seclevel, ref=doc)) 377 378 379 # Add a section marker. 380 out(self.section('%s %s' % (self.doc_kind(doc), _dotted(short_name)), 381 seclevel, ref=doc)) 382 383 # Display our base classes & subclasses 384 out(self.start_of('Class Tree', doc)) 378 385 if ((doc.bases not in (UNKNOWN, None) and len(doc.bases) > 0) or 379 386 (doc.subclasses not in (UNKNOWN,None) and len(doc.subclasses)>0)): … … 399 406 sc_items = [_hyperlink(sc, '%s' % sc.canonical_name) 400 407 for sc in doc.subclasses] 408 out('{\\raggedright%\n') 401 409 out(self._descrlist(sc_items, 'Known Subclasses', short=1)) 410 out('}%\n') 402 411 403 412 # The class's description. 404 413 if doc.descr not in (None, UNKNOWN): 405 out(' '*4 + '\\begin{EpydocClassDescription}\n') 406 out(self.docstring_to_latex(doc.descr, doc)) 407 out(' '*4 + '\\end{EpydocClassDescription}\n') 414 out(self.start_of('Description', doc)) 415 out('\\begin{EpydocClassDescription}%\n') 416 out(self.docstring_to_latex(doc.descr, doc, 4)) 417 out('\\end{EpydocClassDescription}\n') 408 418 409 419 # Version, author, warnings, requirements, notes, etc. 410 self.write_standard_fields(out, doc)420 out(self.metadata(doc)) 411 421 412 422 # Contents. … … 423 433 424 434 # Mark the end of the class (for the index) 425 out(' ' + self.indexterm(doc, 'end')) 435 out(self.start_of('Footer', doc)) 436 out(self.indexterm(doc, 'end')) 426 437 427 438 # Write any nested classes. These will have their own 428 439 # section (at the same level as this section) 429 for nested_class in doc.select_variables(imported=False, 430 value_type='class', 431 public=self._public_filter): 432 if (nested_class.value.canonical_name != UNKNOWN and 433 (nested_class.value.canonical_name[:-1] == 434 doc.canonical_name)): 435 self.write_class(out, nested_class.value, 436 DottedName(short_name, 437 nested_class.canonical_name[-1])) 440 if not self._list_classes_separately: 441 nested_classes = doc.select_variables( 442 imported=False, value_type='class', 443 public=self._public_filter) 444 if nested_classes: 445 out(self.start_of('Nested Classes', doc)) 446 for nested_class in nested_classes: 447 if (nested_class.value.canonical_name != UNKNOWN and 448 (nested_class.value.canonical_name[:-1] == 449 doc.canonical_name)): 450 # don't use \include -- can't be nested. 451 out('\\input{%s-class}\n' % 452 nested_class.value.canonical_name) 438 453 439 454 #//////////////////////////////////////////////////////////// … … 457 472 def write_module_list(self, out, doc): 458 473 if len(doc.submodules) == 0: return 459 self.write_start_of(out, 'Submodules')474 out(self.start_of('Submodules', doc)) 460 475 461 476 out(self.section('Submodules', 1)) … … 480 495 @rtype: C{string} 481 496 """ 482 out(' '*depth + '\\item[%s]' % _hyperlink(doc, doc.canonical_name[-1])) 497 out(' '*depth + '\\item[%s]\n' % 498 _hyperlink(doc, doc.canonical_name[-1])) 483 499 484 500 if doc.summary not in (None, UNKNOWN): 485 out( ' %s\n' % self.docstring_to_latex(doc.summary, doc))501 out(self.docstring_to_latex(doc.summary, doc, depth+2)) 486 502 out(self.crossref(doc) + '\n\n') 487 503 if doc.submodules != UNKNOWN and doc.submodules: … … 499 515 width = self._find_tree_width(doc)+2 500 516 linespec = [] 501 s = ('&'*(width-4)+'\\multicolumn{2}{l}{\\textbf{%s}}\n' % 517 s = (' %% Class tree line for this class (%s)\n ' % 518 doc.canonical_name + '&'*(width-4) + 519 '\\multicolumn{2}{l}{\\textbf{%s}}\n' % 502 520 _dotted('%s'%self._base_name(doc))) 503 521 s += '\\end{tabular}\n\n' … … 535 553 536 554 def _base_tree_line(self, doc, width, linespec): 555 # linespec is a list of booleans. 537 556 base_name = _dotted(self._base_name(doc)) 538 557 539 # linespec is a list of booleans. 540 s = '%% Line for %s, linespec=%s\n' % (base_name, linespec) 541 558 s = ' %% Class tree line for base "%s"\n' % self._base_name(doc) 542 559 labelwidth = width-2*len(linespec)-2 543 560 544 561 # The base class name. 545 s += ('\\multicolumn{%s}{r}{' % labelwidth)546 s += ' \\settowidth{\\EpydocBCL}{%s}' % base_name547 s += ('\\multirow{2}{\\EpydocBCL}{%s}}\n' %548 _hyperlink(doc, self._base_name(doc)))562 s += ' \\multicolumn{%s}{r}{\n' % labelwidth 563 s += ' \\settowidth{\\EpydocBCL}{%s}\n' % base_name 564 s += ' \\multirow{2}{\\EpydocBCL}{\n' 565 s += ' %s}}\n' % _hyperlink(doc, self._base_name(doc)) 549 566 550 567 # The vertical bars for other base classes (top half) 551 568 for vbar in linespec: 552 if vbar: s += ' &&\\multicolumn{1}{|c}{}\n'553 else: s += ' &&\n'569 if vbar: s += ' &&\\multicolumn{1}{|c}{}\n' 570 else: s += ' &&\n' 554 571 555 572 # The horizontal line. 556 s += ' \\\\\\cline{%s-%s}\n' % (labelwidth+1, labelwidth+1)573 s += ' \\\\\\cline{%s-%s}\n' % (labelwidth+1, labelwidth+1) 557 574 558 575 # The vertical bar for this base class. 559 s += ' ' + '&'*labelwidth576 s += ' ' + '&'*labelwidth 560 577 s += '\\multicolumn{1}{c|}{}\n' 561 578 562 579 # The vertical bars for other base classes (bottom half) 563 580 for vbar in linespec: 564 if vbar: s += '&\\multicolumn{1}{|c}{}&\n' 565 else: s += '&&\n' 566 s += ' \\\\\n' 581 if vbar: s += ' &\\multicolumn{1}{|c}{}&\n' 582 else: s += ' &&\n' 583 584 s += ' \\\\\n' 567 585 568 586 return s … … 584 602 585 603 # Write a header. 586 self.write_start_of(out, 'Classes')604 out(self.start_of('Classes', doc)) 587 605 out(self.section('Classes', 1)) 588 606 out('\\begin{EpydocClassList}\n') … … 606 624 var_doc.name)) 607 625 if doc.summary not in (None, UNKNOWN): 608 out(': % s\n' %self.docstring_to_latex(doc.summary, doc))609 out(self.crossref(doc) + '\n\n')626 out(': %\n' + self.docstring_to_latex(doc.summary, doc)) 627 out(self.crossref(doc)) 610 628 611 629 #//////////////////////////////////////////////////////////// … … 628 646 629 647 # Write a header. 630 self.write_start_of(out, heading)631 out( ' '+self.section(heading, seclevel))648 out(self.start_of(heading, doc)) 649 out(self.section(heading, seclevel)) 632 650 633 651 out('\\begin{%s}\n' % list_type) … … 719 737 #{ Function Details 720 738 #//////////////////////////////////////////////////////////// 739 740 def replace_par(self, out): 741 def new_out(s): 742 s = re.sub('(?m)\n([ \t]*\n)+', '\\par\n', s) 743 s = re.sub(r'\\par\b', r'\\EpydocPar', s) 744 s = re.sub(r'(?m)^([ \t]*)([^ \t].*)\\EpydocPar\n', 745 r'\1\2\n\1\\EpydocPar\n', s) 746 out(s) 747 return new_out 721 748 722 749 def write_function(self, out, var_doc): … … 728 755 # directly to the function. 729 756 if not is_inherited: 730 out(' %s%%\n' % self.indexterm(func_doc)) 731 732 # This latex command takes 8 arguments. 733 out('\\EpydocFunction{%\n') 734 757 out(' %s' % self.indexterm(func_doc)) 758 759 out(' \\EpydocFunction{%% <<< %s >>>\n' % var_doc.name) 760 761 # We're passing arguments using xkeyval, which is unhappy if 762 # the arguments contain \par. So replace every occurence of 763 # \par with \EpydocPar (which is defined to just return \par). 764 out = self.replace_par(out) 765 735 766 # Argument 1: the function signature 736 out( self.function_signature(var_doc))737 out('}{%\n')767 out(' signature={%%\n%s }' % 768 self.function_signature(var_doc)) 738 769 739 770 # Argument 2: the function description 740 771 if func_doc.descr not in (None, UNKNOWN): 741 out(self.docstring_to_latex(func_doc.descr, func_doc, 4)) 742 out('}{%\n') 772 out(',\n description={%\n') 773 out(self.docstring_to_latex(func_doc.descr, func_doc, 6)) 774 out(' }') 743 775 744 776 # Argument 3: the function parameter descriptions 745 777 if func_doc.arg_descrs or func_doc.arg_types: 778 out(',\n parameters={%\n') 746 779 self.write_function_parameters(out, var_doc) 747 out('}{%\n')780 out(' }') 748 781 749 782 # Argument 4: The return description 750 783 if func_doc.return_descr not in (None, UNKNOWN): 751 out(self.docstring_to_latex(func_doc.return_descr,752 func_doc, 6))753 out('}{%\n')784 out(',\n returndescr={%\n') 785 out(self.docstring_to_latex(func_doc.return_descr, func_doc, 6)) 786 out(' }') 754 787 755 788 # Argument 5: The return type 756 789 if func_doc.return_type not in (None, UNKNOWN): 757 out(self.docstring_to_latex(func_doc.return_type,758 func_doc, 6).strip())759 out('}{%\n')790 out(',\n returntype={%\n') 791 out(self.docstring_to_latex(func_doc.return_type, func_doc, 6)) 792 out(' }') 760 793 761 794 # Argument 6: The raises section 762 795 if func_doc.exception_descrs not in (None, UNKNOWN, [], ()): 796 out(',\n raises={%\n') 763 797 out(' '*6+'\\begin{EpydocFunctionRaises}\n') 764 798 for name, descr in func_doc.exception_descrs: … … 766 800 plaintext_to_latex('%s' % name)) 767 801 out(self.docstring_to_latex(descr, func_doc, 10)) 768 out(' '*6+'\\end{EpydocFunctionRaises}\n \n')769 out('}{%\n')802 out(' '*6+'\\end{EpydocFunctionRaises}\n') 803 out(' }') 770 804 771 805 # Argument 7: The overrides section 772 806 if var_doc.overrides not in (None, UNKNOWN): 807 out(',\n overrides={%\n') 773 808 out('\\EpydocFunctionOverrides') 774 809 if (func_doc.docstring in (None, UNKNOWN) and 775 810 var_doc.overrides.value.docstring not in (None, UNKNOWN)): 776 811 out('[1]') 777 out('{%s}\n \n'812 out('{%s}\n' 778 813 % _hyperlink(var_doc.overrides, 779 814 '%s' % var_doc.overrides.canonical_name)) 780 out('}{%\n')815 out(' }') 781 816 782 817 # Argument 8: The metadata section 783 self.write_standard_fields(out, func_doc) 784 out('}\n') 785 818 metadata = self.metadata(func_doc, 6) 819 if metadata: 820 out(',\n metadata={%%\n%s }' % metadata) 821 822 out('}%\n') 786 823 787 824 def write_function_parameters(self, out, var_doc): … … 804 841 for (arg_names, arg_descr) in arg_descrs: 805 842 arg_name = plaintext_to_latex(', '.join(arg_names)) 806 out('%s\\item[%s]\n \n' % (' '*10, arg_name))843 out('%s\\item[%s]\n' % (' '*8, arg_name)) 807 844 if arg_descr: 808 845 out(self.docstring_to_latex(arg_descr, func_doc, 10)) … … 817 854 else: 818 855 lhs = 'type of %s' % arg_name 819 rhs = self.docstring_to_latex(arg_typ, func_doc).strip() 820 out('%s{\\it (%s=%s)}\n\n' % (' '*12, lhs, rhs)) 821 out(' '*6+'\\end{EpydocFunctionParameters}\n\n') 822 823 def function_signature(self, var_doc): 856 rhs = self.docstring_to_latex(arg_typ, func_doc, 14) 857 out('%s\\textit{ (%s=%%\n%s%s)}\n' % (' '*12, lhs, 858 rhs, ' '*12)) 859 out(' '*6+'\\end{EpydocFunctionParameters}\n') 860 861 def function_signature(self, var_doc, indent=6): 824 862 func_doc = var_doc.value 825 863 func_name = var_doc.name 826 864 827 s = (' \\begin{EpydocFunctionSignature}{%s}%%\n' %828 _hypertarget(var_doc, func_name))865 s = ('%s\\begin{EpydocFunctionSignature}%%\n%s {%s}%%\n' % 866 (indent*' ', indent*' ', _hypertarget(var_doc, func_name))) 829 867 830 868 # This should never happen, but just in case: … … 843 881 if func_doc.kwarg: 844 882 args.append('\\KWArg{%s}' % plaintext_to_latex(func_doc.kwarg))
FiPy: A Finite Volume PDE Solver Using Python