[Epydoc-commits] SF.net SVN: epydoc: [1769] trunk/epydoc
Brought to you by:
edloper
|
From: <ed...@us...> - 2008-02-24 03:41:24
|
Revision: 1769
http://epydoc.svn.sourceforge.net/epydoc/?rev=1769&view=rev
Author: edloper
Date: 2008-02-23 19:41:21 -0800 (Sat, 23 Feb 2008)
Log Message:
-----------
- Added the latex commands \EpydocUserSection, \EpydocUserSubsection,
and \EpydocUserSubsubsection, used to add section headings inside of
docstrings.
- Added TEMPLATE to latex stylesheets
Modified Paths:
--------------
trunk/epydoc/doc/epydoc-latex-demo.tex
trunk/epydoc/src/epydoc/docwriter/latex_sty.py
trunk/epydoc/src/epydoc/markup/epytext.py
trunk/epydoc/src/epydoc/markup/restructuredtext.py
Modified: trunk/epydoc/doc/epydoc-latex-demo.tex
===================================================================
--- trunk/epydoc/doc/epydoc-latex-demo.tex 2008-02-23 20:52:35 UTC (rev 1768)
+++ trunk/epydoc/doc/epydoc-latex-demo.tex 2008-02-24 03:41:21 UTC (rev 1769)
@@ -13,7 +13,11 @@
\usepackage[index]{epydoc}
\usepackage[utf8]{inputenc}
\definecolor{UrlColor}{rgb}{0,0.08,0.45}
-\usepackage[pdftex, pagebackref, pdftitle={API Documentation}, pdfcreator={epydoc 3.0.1}, bookmarks=true, bookmarksopen=false, pdfpagemode=UseOutlines, colorlinks=true, linkcolor=black, anchorcolor=black, citecolor=black, filecolor=black, menucolor=black, pagecolor=black, urlcolor=UrlColor]{hyperref}
+\usepackage[pdftex, pagebackref, pdftitle={API Documentation}, %
+ pdfcreator={epydoc 3.0.1}, bookmarks=true, bookmarksopen=false, %
+ pdfpagemode=UseOutlines, colorlinks=true, linkcolor=black, %
+ anchorcolor=black, citecolor=black, filecolor=black, menucolor=black, %
+ pagecolor=black, urlcolor=UrlColor]{hyperref}
\begin{document}
\title{Epydoc LaTeX Writer Output Demo}
@@ -86,6 +90,15 @@
This is a note.
\end{reSTadmonition}
+\subsubsection{Sections inside Docstrings}
+
+% The commands \EpydocUserSection, \EpydocUserSubsection, and
+% \EpydocUserSubsubsection are used to add section headings inside
+% of docstrings
+\EpydocUserSection{Intra-docstring heading 1}
+\EpydocUserSubsection{Intra-docstring heading 2}
+\EpydocUserSubsubsection{Intra-docstring heading 3}
+
% ======================================================================
% Each module is listed in its own section. (These sections are created
Modified: trunk/epydoc/src/epydoc/docwriter/latex_sty.py
===================================================================
--- trunk/epydoc/src/epydoc/docwriter/latex_sty.py 2008-02-23 20:52:35 UTC (rev 1768)
+++ trunk/epydoc/src/epydoc/docwriter/latex_sty.py 2008-02-24 03:41:21 UTC (rev 1769)
@@ -109,6 +109,18 @@
\newlength{\EpydocBCL} % base class length, for base trees.
% ======================================================================
+% Sections inside docstring
+
+% The following commands are used to mark section headers within
+% docstrings.
+\newcommand\EpydocUserSection[1]{%
+ \par\vspace{3ex}{\large\bf #1 }\par\vspace{1.4ex}}
+\newcommand\EpydocUserSubsection[1]{%
+ \par\vspace{2.8ex}{\bf #1 }\par\vspace{1.2ex}}
+\newcommand\EpydocUserSubsubsection[1]{%
+ \par\vspace{2.6ex}{\bf\it #1 }\par\vspace{1.0ex}}
+
+% ======================================================================
% Hyperlinks & Crossreferences
% The \EpydocHypertarget command is used to mark targets that hyperlinks
@@ -801,8 +813,7 @@
SHADED = r"""
% epydoc-shaded.sty
%
-% Authors: Jonathan Guyer <gu...@ni...>
-% Edward Loper <ed...@se...>
+% Author: Edward Loper <ed...@se...>
% URL: <http://epydoc.sf.net>
%
% This LaTeX stylesheet for epydoc's output uses shaded boxes to
@@ -1052,6 +1063,27 @@
{\raggedright\normalfont\normalsize\bfseries}}
"""
+######################################################################
+######################################################################
+
+TEMPLATE = r"""
+% epydoc-template.sty
+%
+% This is a starting point for creating new epydoc style files.
+% Add on \renewcommand and \renewenvironment commands to change
+% how different pieces of the documentation are displayed.
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{epydoc}[2007/04/06 v3.0beta1 Epydoc Python Documentation]
+\DeclareOption{index}{\PassOptionsToPackage{index}{epydoc-base}}
+\DeclareOption{hyperlink}{\PassOptionsToPackage{hyperlink}{epydoc-base}}
+\ProcessOptions\relax
+
+\RequirePackage{epydoc-base}
+
+% Add \renewcommand and \renewenvironment commands here.
+"""
+
############################################################
## Stylesheet table
############################################################
@@ -1061,4 +1093,5 @@
'boxes': BOXES,
'shaded': SHADED,
'default': BOXES,
+ 'template': TEMPLATE,
}
Modified: trunk/epydoc/src/epydoc/markup/epytext.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/epytext.py 2008-02-23 20:52:35 UTC (rev 1768)
+++ trunk/epydoc/src/epydoc/markup/epytext.py 2008-02-24 03:41:21 UTC (rev 1769)
@@ -1986,7 +1986,9 @@
elif tree.tag == 'li':
return indent*' ' + '\\item ' + childstr.lstrip()
elif tree.tag == 'heading':
- return ' '*(indent-2) + '(section) %s\n\n' % childstr
+ sec = ('\\EpydocUser' +
+ ('%ssection' % ('sub'*(min(seclevel,3)-1))).capitalize())
+ return (' '*(indent-2) + '%s{%s}\n\n' % (sec, childstr.strip()))
elif tree.tag == 'doctestblock':
return doctest_to_latex(tree.children[0].strip())
elif tree.tag == 'literalblock':
Modified: trunk/epydoc/src/epydoc/markup/restructuredtext.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/restructuredtext.py 2008-02-23 20:52:35 UTC (rev 1768)
+++ trunk/epydoc/src/epydoc/markup/restructuredtext.py 2008-02-24 03:41:21 UTC (rev 1769)
@@ -544,6 +544,16 @@
_TARGET_RE = re.compile(r'^(.*?)\s*<(?:URI:|URL:)?([^<>]+)>$')
+class _EpydocDocumentClass:
+ SECTIONS = ['EpydocUserSection',
+ 'EpydocUserSubsection',
+ 'EpydocUserSubsubsection']
+ def section(self, level):
+ if level <= len(self.SECTIONS):
+ return self.SECTIONS[level-1]
+ else:
+ return self.SECTIONS[-1]
+
class _EpydocLaTeXTranslator(LaTeXTranslator):
settings = None
def __init__(self, document, docstring_linker=None, directory=None,
@@ -552,6 +562,11 @@
if self.settings is None:
settings = OptionParser([LaTeXWriter()]).get_default_values()
settings.output_encoding = 'utf-8'
+
+ # This forces eg \EpydocUserSection rather than
+ # \EpydocUserSEction*:
+ settings.use_latex_toc = True
+
self.__class__.settings = settings
document.settings = self.settings
@@ -561,11 +576,8 @@
self._docindex = docindex
self._context = context
- # Start at section level 3. (Unfortunately, we now have to
- # set a private variable to make this work; perhaps the standard
- # latex translator should grow an official way to spell this?)
- self.section_level = 3
- self._section_number = [0]*self.section_level
+ # Use custom section names.
+ self.d_class = _EpydocDocumentClass()
# Handle interpreted text (crossreferences)
def visit_title_reference(self, node):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|