[los-cocos] r1350 committed - deleting unesed epydoc relatedfiles

1 view
Skip to first unread message

los-...@googlecode.com

unread,
Mar 20, 2014, 1:06:27 PM3/20/14
to cocos-...@googlegroups.com
Revision: 1350
Author: ccanepacc
Date: Thu Mar 20 17:06:09 2014 UTC
Log: deleting unesed epydoc relatedfiles
http://code.google.com/p/los-cocos/source/detail?r=1350

Deleted:
/trunk/tools/epydoc.config
/trunk/tools/epydoc_cocos.css
/trunk/tools/gendoc.sh
/trunk/tools/gendoc_html.py
/trunk/tools/gendoc_pdf.py

=======================================
--- /trunk/tools/epydoc.config Sat May 3 21:59:24 2008 UTC
+++ /dev/null
@@ -1,18 +0,0 @@
-[epydoc]
-name: cocos2d API reference
-url: http://www.cocos2d.org/
-
-output: html
-target: doc/html/api/
-inheritance: included
-private: no
-imports: no
-sourcecode: no
-include-log: no
-
-parse: yes
-introspect: yes
-
-modules: cocos cocos.director.Director
-
-exclude: cocos.euclid|cocos.gl_.*|cocos.path|pyglet.*
=======================================
--- /trunk/tools/epydoc_cocos.css Thu May 1 22:58:25 2008 UTC
+++ /dev/null
@@ -1,324 +0,0 @@
-
-
-/* Epydoc CSS Stylesheet for pyglet
- *
- * This stylesheet can be used to customize the appearance of epydoc's
- * HTML output.
- *
- */
-
-/* Default Colors & Styles
- * - Set the default foreground & background color with 'body'; and
- * link colors with 'a:link' and 'a:visited'.
- * - Use bold for decision list terms.
- * - The heading styles defined here are used for headings *within*
- * docstring descriptions. All headings used by epydoc itself use
- * either class='epydoc' or class='toc' (CSS styles for both
- * defined below).
- */
-body { background: #ffffff; color: #000000; }
-dt { font-weight: normal; }
-
-/* Page Header & Footer
- * - The standard page header consists of a navigation bar (with
- * pointers to standard pages such as 'home' and 'trees'); a
- * breadcrumbs list, which can be used to navigate to containing
- * classes or modules; options links, to show/hide private
- * variables and to show/hide frames; and a page title (using
- * <h1>). The page title may be followed by a link to the
- * corresponding source code (using 'span.codelink').
- * - The footer consists of a navigation bar, a timestamp, and a
- * pointer to epydoc's homepage.
- */
-
-table.navbar {
- border-top: 1px solid silver;
- border-bottom: 2px solid silver;
- padding: 0px;
- font-family: sans-serif;
- font-size: 80%;
- width: 100%;
-}
-table.navbar th {
- padding-right: 1em;
- font-weight: normal;
-}
-table.navbar th.last {
- text-align: right;
- padding-right: 0px;
-}
-table.navbar a {
- text-decoration: none;
-}
-th.navbar-breadcrumbs {
- text-align: center;
- width: 100%;
-}
-
-/*
-.breadcrumbs {
- font-family: sans-serif;
-}
-*/
-
-h1.epydoc {
- font-family: Arial, sans-serif;
- font-size: 20pt;
- font-weight: normal;
-}
-
-h1 {
- font-family: Aria, sans-serif;
- font-size: 16pt;
- font-weight: normal;
-}
-
-h2 {
- font-size: 16pt;
- color: #ff6161;
- font-weight: normal;
- font-family: sans-serif;
-}
-
-h3 {
- margin-bottom: .5em;
-}
-
-
-/* Frames-based table of contents headers
- * - Consists of two frames: one for selecting modules; and
- * the other listing the contents of the selected module.
- * - h1.toc is used for each frame's heading
- * - h2.toc is used for subheadings within each frame.
- */
-h1.toc {
- font-size: 105%;
- font-weight: bold;
- font-family: sans-serif;
- margin: 0;
- padding: 0;
-}
-h2.toc {
- font-size: 100%;
- color: black;
- margin-bottom: 0.5em;
- border-bottom: 1px solid black;
-}
-
-
-span.options { font-size: 70%; }
-span.codelink { font-size: 85%; }
-td.footer { font-size: 85%; }
-
-
-th.group-header { text-align: left; font-style: italic;
- font-size: 115%;
- border: 1px solid #608090; }
-
-
-table.summary { border-collapse: collapse;
- border: 1px solid silver;
- margin-bottom: 0.5em;
- width: 100%;}
-.summary td {
- border: 1px solid silver;
- padding: 5px;
-}
-code.summary-type { font-size: 85%; }
-span.inherited-from { font-size: 85%; }
-
-
-/* Fields */
-dl.fields { margin-left: 0px; margin-top: 1em;
- margin-bottom: 1em; }
-dl.fields > dt { font-weight: bold; }
-dl.fields > dd { margin-bottom: 1em; }
-div.fields { }
-div.fields p { margin-bottom: 0.5em; }
-
-/* Index tables (identifier index, term index, etc)
- * - link-index is used for indices containing lists of links
- * (namely, the identifier index & term index).
- * - index-where is used in link indices for the text indicating
- * the container/source for each link.
- * - metadata-index is used for indices containing metadata
- * extracted from fields (namely, the bug index & todo index).
- */
-table.link-index { border-collapse: collapse;
- border: 1px solid silver; }
-td.link-index { border-width: 0px; }
-span.index-where { font-size: 70%; }
-table.metadata-index { border-collapse: collapse;
- border: 1px solid #608090;
- margin: .2em 0 0 0; }
-td.metadata-index { border-width: 1px; border-style: solid; }
-.link-index a {
- text-decoration: none;
-}
-
-
-/* Summaries */
-
-.sig-name { }
-.sig-arg { }
-.sig-default { }
-.summary-sig { font-family: monospace; }
-.summary-sig-name { font-weight: bold; }
-a.summary-sig-name {
- text-decoration: none;
-}
-
-.summary-name {
- font-family: monospace;
- font-weight: bold;
- text-decoration: none;
-}
-
-.summary-sig-arg { }
-.summary-sig-default { }
-.summary-type { font-family: monospace; }
-.summary-description { margin-left: 1em; }
-
-/* Details */
-
-.fspecial {
- font-family: serif;
- font-style: italic;
-}
-
-.detail {
- border-top: 1px solid silver;
-}
-
-.detail-signature {
- font-family: monospace;
- margin-top: .5em;
- margin-bottom: .5em;
-}
-
-.detail-description {
- margin-top: .5em;
- margin-left: 2em;
-}
-
-.pname {
- font-family: monospace;
- font-weight: bold;
-}
-
-.ptype {
- font-family: monospace;
-}
-
-.ptype a {
- text-decoration: none;
-}
-
-.rtype, .overrides {
- font-family: monospace;
-}
-
-.rtype a, .overrides a {
- text-decoration: none;
-}
-
-
-/* To render variables, classes etc. like functions */
-/*
-table.summary .summary-name { font-weight: bold;
- font-family: monospace; }
-table.summary
- a.summary-name:link { font-weight: bold;
- font-family: monospace; }
-table.summary
- a.summary-name:visited { font-weight: bold;
- font-family: monospace; }*/
-
-/* Variable values
- * - In the 'variable details' sections, each varaible's value is
- * listed in a 'pre.variable' box. The width of this box is
- * restricted to 80 chars; if the value's repr is longer than
- * this it will be wrapped, using a backslash marked with
- * class 'variable-linewrap'. If the value's repr is longer
- * than 3 lines, the rest will be ellided; and an ellipsis
- * marker ('...' marked with 'variable-ellipsis') will be used.
- * - If the value is a string, its quote marks will be marked
- * with 'variable-quote'.
- * - If the variable is a regexp, it is syntax-highlighted using
- * the re* CSS classes.
- */
-.variable-linewrap { color: #604000; font-weight: bold; }
-.variable-ellipsis { color: #604000; font-weight: bold; }
-.variable-quote { color: #604000; font-weight: bold; }
-.variable-group { color: #008000; font-weight: bold; }
-.variable-op { color: #604000; font-weight: bold; }
-.variable-string { color: #006030; }
-.variable-unknown { color: #a00000; font-weight: bold; }
-.re { color: #000000; }
-.re-char { color: #006030; }
-.re-op { color: #600000; }
-.re-group { color: #003060; }
-.re-ref { color: #404040; }
-
-/* Base tree
- * - Used by class pages to display the base class hierarchy.
- */
-pre.base-tree { font-size: 80%; margin: 0; }
-
-
-/*---------------------------------------------------------------------
- Custom epydoc source coloring
- ---------------------------------------------------------------------*/
-pre.py-doctest, pre.variable
- { padding: .5em; margin: 1em;
- color: #000000;
- border-left: 2px solid silver; }
-pre.py-src { border: 2px solid #000000;
- background: #f0f0f0; color: #000000; }
-.py-line { border-left: 2px solid #000000;
- margin-left: .2em; padding-left: .4em; }
-.py-lineno { font-style: italic; font-size: 90%;
- padding-left: .5em; }
-a.py-toggle { text-decoration: none; }
-div.py-highlight-hdr { border-top: 2px solid #000000;
- border-bottom: 2px solid #000000;
- background: #d8e8e8; }
-/*div.py-highlight { border-bottom: 2px solid #000000;
- background: #d0e0e0; }*/
-.py-prompt { color: #005050; font-weight: bold;}
-.py-more { color: #005050; font-weight: bold;}
-.py-string { color: #006030; }
-.py-comment { color: #003060; }
-.py-keyword { color: #600000; }
-.py-output { color: #404040; }
-.py-name { color: #000050; }
-.py-name:link { color: #000050 !important; }
-.py-name:visited { color: #000050 !important; }
-.py-number { color: #005000; }
-.py-defname { color: #000060; font-weight: bold; }
-.py-def-name { color: #000060; font-weight: bold; }
-.py-base-class { color: #000060; }
-.py-param { color: #000060; }
-.py-docstring { color: #006030; }
-.py-decorator { color: #804020; }
-
-/* HTML Log */
-div.log-block { padding: 0; margin: .5em 0 .5em 0;
- background: #e8f0f8; color: #000000;
- border: 1px solid #000000; }
-div.log-error { padding: .1em .3em .1em .3em; margin: 4px;
- background: #ffb0b0; color: #000000;
- border: 1px solid #000000; }
-div.log-warning { padding: .1em .3em .1em .3em; margin: 4px;
- background: #ffffb0; color: #000000;
- border: 1px solid #000000; }
-div.log-info { padding: .1em .3em .1em .3em; margin: 4px;
- background: #b0ffb0; color: #000000;
- border: 1px solid #000000; }
-h2.log-hdr { background: #70b0ff; color: #000000;
- margin: 0; padding: 0em 0.5em 0em 0.5em;
- border-bottom: 1px solid #000000; font-size:
110%; }
-p.log { font-weight: bold; margin: .5em 0 .5em 0; }
-tr.opt-changed { color: #000000; font-weight: bold; }
-tr.opt-default { color: #606060; }
-pre.log { margin: 0; padding: 0; padding-left: 1em; }
=======================================
--- /trunk/tools/gendoc.sh Sat Dec 27 01:53:00 2008 UTC
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/bash
-# $Id:$
-
-TOOLS=`dirname $0`
-BASE=$TOOLS/..
-PYGLETBASE=~/src/pyglet-svn/
-EPYDOC=$PYGLETBASE/tools/epydoc
-PYTHONPATH=$EPYDOC:$BASE:$PYTHONPATH
-export PYTHONPATH
-
-DOC=$BASE/doc
-DOC_HTML=$DOC/html
-DOC_HTML_API=$DOC_HTML/api
-DOC_HTML_GUIDE=$DOC_HTML/programming_guide
-DOC_HTML_FAQ=$DOC_HTML/faq
-DOC_HTML_TUTORIAL=$DOC_HTML/tutorial
-DOC_PDF=$DOC/pdf
-
-function clean() {
- # Clean old docs, not needed usually
- echo "Removing doc directories..."
- rm -rf $DOC_HTML
- rm -rf $DOC_PDF
-}
-
-function html_api() {
- # Generate API (html) docs
- echo "Generating HTML API..."
- rm -rf $DOC_HTML_API
- mkdir -p $DOC_HTML_API
- $EPYDOC/scripts/epydoc \
- --config=$TOOLS/epydoc.config \
- --css=$TOOLS/epydoc_cocos.css \
- -v --debug
-}
-
-function html_guide() {
- echo "Generating HTML guide..."
- # Generate html docs
- rm -rf $DOC_HTML_GUIDE
- mkdir -p $DOC_HTML_GUIDE
- mkdir -p $DOC_HTML_GUIDE/skeleton
- $TOOLS/gendoc_html.py \
- --apidoc-dir=$DOC_HTML_API \
- --html-dir=$DOC_HTML_GUIDE \
- --depth=1 \
- --add-navigation \
- $DOC/programming_guide/index.txt
-
- $TOOLS/gendoc_html.py \
- --html-dir=$DOC_HTML \
- $DOC/index.txt
-
- # Copy stylesheet
- cp $DOC/doc.css $DOC_HTML/doc.css
- cp $DOC/doc.css $DOC_HTML_GUIDE/doc.css
-}
-
-function html_faq() {
- echo "Generating HTML faq..."
- # Generate html docs
- rm -rf $DOC_HTML_FAQ
- mkdir -p $DOC_HTML_FAQ
- $TOOLS/gendoc_html.py \
- --apidoc-dir=$DOC_HTML_API \
- --html-dir=$DOC_HTML_FAQ\
- --depth=0 \
- --add-navigation \
- $DOC/faq/index.txt
-
- $TOOLS/gendoc_html.py \
- --html-dir=$DOC_HTML \
- $DOC/index.txt
-
- # Copy stylesheet
- cp $DOC/doc.css $DOC_HTML/doc.css
- cp $DOC/doc.css $DOC_HTML_FAQ/doc.css
-}
-
-function html_tutorial() {
- echo "Generating HTML tutorial..."
- # Generate html docs
- rm -rf $DOC_HTML_TUTORIAL
- mkdir -p $DOC_HTML_TUTORIAL
- $TOOLS/gendoc_html.py \
- --apidoc-dir=$DOC_HTML_API \
- --html-dir=$DOC_HTML_TUTORIAL \
- --depth=1 \
- --add-navigation \
- $DOC/tutorial/index.txt
-
- $TOOLS/gendoc_html.py \
- --html-dir=$DOC_HTML \
- $DOC/index.txt
-
- # Copy stylesheet
- cp $DOC/doc.css $DOC_HTML/doc.css
- cp $DOC/doc.css $DOC_HTML_TUTORIAL/doc.css
-}
-
-function pdf_guide() {
- echo "Generating PDF guide..."
- # hack this on
- python $TOOLS/gendoc_pdf.py
-}
-
-function usage() {
- echo "Usage: $0 ([clean] [html-api] [html-tutorial] [html-guide]
[html-faq] [pdf-guide]) | all"
-}
-
-if [ -z "$1" ]
-then
- usage
-fi
-
-until [ -z "$1" ]
-do
- case "$1" in
- "clean" ) clean;;
- "html-api" ) html_api;;
- "html-guide") html_guide;;
- "html-faq") html_faq;;
- "html-tutorial") html_tutorial;;
- "pdf-guide" ) pdf_guide;;
- "all" ) clean; html_api; html_guide; html_faq; pdf_guide;; #
skip tutorial
- * ) usage; exit 1;;
- esac
- shift
-done
=======================================
--- /trunk/tools/gendoc_html.py Mon Jun 11 11:39:24 2012 UTC
+++ /dev/null
@@ -1,383 +0,0 @@
-#!/usr/bin/env python
-# $Id:$
-
-import optparse
-import os
-import os.path
-import re
-import shutil
-import subprocess
-
-from docutils.core import publish_doctree, publish_from_doctree
-from docutils.utils import new_document
-from docutils.writers import html4css1
-from docutils import nodes
-
-from epydoc.markup.doctest import HTMLDoctestColorizer
-
-class HTMLWriter(html4css1.Writer):
- def __init__(self):
- html4css1.Writer.__init__(self)
- self.translator_class = HTMLTranslator
-
-class HTMLTranslator(html4css1.HTMLTranslator):
- def visit_reference(self, node):
- # Copied from html4css1.Writer but extended to add "title"
attribute.
- if node.has_key('refuri'):
- href = node['refuri']
- if ( self.settings.cloak_email_addresses
- and href.startswith('mailto:')):
- href = self.cloak_mailto(href)
- self.in_mailto = 1
- else:
- assert node.has_key('refid'), \
- 'References must have "refuri" or "refid" attribute.'
- href = '#' + node['refid']
- atts = {'href': href, 'class': 'reference'}
- if not isinstance(node.parent, nodes.TextElement):
- assert len(node) == 1 and isinstance(node[0], nodes.image)
- atts['class'] += ' image-reference'
- if node.has_key('link_class'):
- atts['class'] += ' %s' % node['link_class']
- if node.has_key('title'):
- atts['title'] = node['title']
- self.body.append(self.starttag(node, 'a', '', **atts))
-
-def convert_image(uri, input_dir, html_dir):
- '''Convert image found at uri in input_dir to something useable and
place
- in html_dir. Return the new uri.'''
-
- # Bail if it's external
- if uri.startswith('http:'):
- return uri
-
- input_file = os.path.join(input_dir, uri)
- if not os.path.exists(input_file):
- print 'Not found: %s' % uri
- return uri
-
- if uri.endswith('.svg'):
- # Convert SVG to PNG using Inkscape
- newuri = '%s.png' % os.path.splitext(os.path.basename(uri))[0]
- output_file = os.path.join(html_dir, newuri)
- #subprocess.call('convert %s %s' % (input_file, output_file),
- # shell=True)
- subprocess.call('inkscape --export-png=%s %s' % \
- (output_file, input_file),
- shell=True)
- return newuri
- elif uri.endswith('.png') or uri.endswith('.jpg'):
- # Copy image to output dir
- output_file = os.path.join(html_dir, uri)
- shutil.copy(input_file, output_file)
- return uri
-
-
-def shorten(title):
- words = title.split()
- if len(words) <= 3:
- return ' '.join(words)
- else:
- return ' '.join(words[:2]) + ' ...'
-
-class Page(object):
- def __init__(self, document, filename, parent, ids):
- self.document = document
- self.filename = filename
- self.parent = parent
- self.ids = ids
- self.children = []
-
- # Look for breadcrumb name (title)
- self.title = None
- for field in [n for n in document.traverse() \
- if isinstance(n, nodes.field)]:
- i = field.first_child_matching_class(nodes.field_name)
- if field[i].astext() == 'breadcrumb':
- j = field.first_child_matching_class(nodes.field_body)
- self.title = field[j].astext()
- field.parent.remove(field)
-
- # No breadcrumb field, use title
- if self.title is None:
- title_i = document.first_child_matching_class(nodes.Titular)
- if title_i is not None:
- self.title = self.document[title_i].astext()
- else:
- self.title = self.filename
- document['title'] = self.title
-
- def split(self, depth):
- # Remove sections that are children of document and create
- # new pages out of them.
- for section in [n for n in self.document.children \
- if isinstance(n, nodes.section)]:
- self.document.children.remove(section)
-
- ids = section.attributes['ids']
- filename = '%s.html' % ids[0].replace('-', '_')
- document = new_document(filename)
- for child in section.children:
- document += child.deepcopy()
- page = Page(document, filename, self, ids)
- self.children.append(page)
- if depth:
- page.split(depth - 1)
-
- def collect_ids(self, id_map):
- for id in self.ids:
- id_map[id] = self.filename
-
- for node in self.document.traverse():
- if hasattr(node, 'attributes'):
- for id in node.attributes.get('ids', ()):
- uri = '%s#%s' % (self.filename, id)
- id_map[id] = uri
-
- for child in self.children:
- child.collect_ids(id_map)
-
- def add_refuri(self, id_map):
- for node in self.document.traverse():
- if hasattr(node, 'attributes'):
- refid = node.attributes.get('refid')
- if refid in id_map:
- node.attributes['refuri'] = id_map[refid]
-
- for child in self.children:
- child.add_refuri(id_map)
-
- def add_navigation(self, previous, next):
- navigation = nodes.container()
- navigation['classes'] += ['navigation']
- paragraph = nodes.paragraph()
- navigation += paragraph
-
- if previous:
- inline = nodes.inline()
- inline['classes'] += ['previous']
- inline += nodes.Text('Previous: ')
- inline += previous.create_short_reference()
- paragraph += inline
-
- if next:
- inline = nodes.inline()
- inline['classes'] += ['next']
- inline += nodes.Text('Next: ')
- inline += next.create_short_reference()
- paragraph += inline
-
- breadcrumbs = self.create_short_breadcrumbs()
- if breadcrumbs:
- inline = nodes.inline()
- inline['classes'] += ['breadcrumbs']
- for breadcrumb in breadcrumbs:
- inline += breadcrumb
- inline += nodes.Text(u' \u00bb ')
- inline += nodes.Text(shorten(self.title))
- paragraph += inline
-
- header = navigation.deepcopy()
- header['classes'] += ['navigation-header']
- self.document.insert(0, header)
-
- footer = navigation.deepcopy()
- footer['classes'] += ['navigation-footer']
- self.document += footer
-
- def create_breadcrumbs(self):
- if self.parent:
- return (self.parent.create_breadcrumbs() +
- [self.parent.create_reference()])
- else:
- return []
-
- def create_short_breadcrumbs(self):
- if self.parent:
- return (self.parent.create_short_breadcrumbs() +
- [self.parent.create_short_reference()])
- else:
- return []
-
- def create_reference(self):
- ref = nodes.reference()
- ref['refuri'] = self.filename
- ref['name'] = self.title
- ref += nodes.Text(self.title)
- return ref
-
- def create_short_reference(self):
- ref = nodes.reference()
- ref['refuri'] = self.filename
- ref['name'] = self.title
- ref['title'] = self.title
- ref += nodes.Text(shorten(self.title))
- return ref
-
- def preorder(self):
- yield self
- for child in self.children:
- for c in child.preorder():
- yield c
-
-class PythonColorizer(HTMLDoctestColorizer):
- strong_re = re.compile('(.*)\*\*STRONG_LINE\*\*')
-
- def colorize_codeblock(self, s):
- text = HTMLDoctestColorizer.colorize_codeblock(self, s)
- text = self.strong_re.sub(self.sub_strong_line, text)
- return text
-
- def sub_strong_line(self, match):
- return '<strong>%s</strong>' % match.group(1)
-
- def markup(self, s, tag):
- if tag == 'comment' and s[1:].strip() == '***':
- return '**STRONG_LINE**'
- return HTMLDoctestColorizer.markup(self, s, tag)
-
-def gendoc_html(input_file, html_dir, api_objects, options):
- input_dir = os.path.dirname(input_file)
- files = []
- titles = {}
-
- # XXX Should calculate how apidoc_dir is relative to html_dir...
- apidoc_dir_rel = '../api'
-
- # Read root doctree
- doctree = publish_doctree(open(input_file).read(),
source_path=input_file)
-
- # Convert images
- for image in [n for n in doctree.traverse() if isinstance(n,
nodes.image)]:
- uri = image.attributes['uri']
- image.attributes['uri'] = convert_image(uri, input_dir, html_dir)
-
- # Colorize literal blocks
- for block in [n for n in doctree.traverse() \
- if (isinstance(n, nodes.literal_block))]:
- pysrc = block.astext()
- html = PythonColorizer().colorize_codeblock(pysrc)
- raw = nodes.raw(text=html, format='html')
- block.replace_self(raw)
-
- # Recursively split sections down to depth N into separate doctrees
- root_filename = os.path.splitext(os.path.basename(input_file))[0]
- root_page = Page(doctree,
- '%s.html' % root_filename,
- None, [])
- if options.depth:
- root_page.split(options.depth)
-
- # Add refuri to all references that use refid, to point to the
- # appropriate page.
- id_map = {} # Map id of nodes to uri
- root_page.collect_ids(id_map)
- # Only works for explicit section links; see future uses of id_map
- root_page.add_refuri(id_map)
-
- # Get page connectivity and add navigation
- pages = [n for n in root_page.preorder()]
- if options.add_navigation:
- for i, page in enumerate(pages):
- if i > 0:
- previous = pages[i - 1]
- else:
- previous = None
- if i + 1 < len(pages):
- next = pages[i + 1]
- else:
- next = None
- page.add_navigation(previous, next)
-
-
- for page in pages:
- # Resolve links
- linked_objects = set()
- for ref in [n for n in page.document.traverse() \
- if isinstance(n, nodes.title_reference)]:
- title = ref.astext()
- url = None
- if title.endswith('.py'):
- # Copy in referenced example program and link.
- shutil.copy(title, html_dir)
- url = os.path.basename(title)
- canonical = title
- link_class = 'filelink'
- elif title in api_objects and api_objects[title][0]:
- # Link to API page
- canonical, uri = api_objects[title]
- url = os.path.join(apidoc_dir_rel, uri)
- link_class = 'apilink'
- elif title.lower().replace(' ', '-') in id_map:
- # Section link (using `xx` instead of `xx`_).
- canonical = title
- url = id_map[title.lower().replace(' ', '-')]
- link_class = 'sectionlink'
-
- # Only link once per page, to avoid littering the text
- # with too many links
- if url and url not in linked_objects:
- linked_objects.add(url)
-
- newref = nodes.reference()
- newref.children = [c.deepcopy() for c in ref.children]
- newref['refuri'] = url
- if canonical != title:
- newref['title'] = canonical # tooltip is canonical name
- if link_class:
- newref['link_class'] = link_class
- ref.replace_self(newref)
-
- # Write page
- settings = {
- 'embed_stylesheet': False,
- 'stylesheet': 'doc.css',
- 'stylesheet_path': None,
- }
- writer = HTMLWriter()
- html = publish_from_doctree(page.document,
- writer=writer,
- settings_overrides=settings)
- output_file = open(os.path.join(html_dir, page.filename), 'w')
- output_file.write(html)
-
-def get_api_objects(apidoc_dir):
- '''Return a dict of name -> (canonical, uri) of api_objects exported
from
- epydoc.'''
- objects = {}
-
- # Read API doc objects
- apidoc_file = open(os.path.join(apidoc_dir, 'api-objects.txt'))
- for line in apidoc_file:
- name, url = line.split('\t')
-
- # Canonical name always matches
- objects[name] = (name, url)
- canonical = name
- # Also strip off leading components one at a time and add if not
- # ambiguous
- while '.' in name:
- name = name.split('.', 1)[1]
- if name in objects and (canonical, url) != objects[name]:
- objects[name] = (None, None) # Ambiguous: don't match
- else:
- objects[name] = (canonical, url)
-
- return objects
-
-
-if __name__ == '__main__':
- op = optparse.OptionParser()
- op.add_option('--apidoc-dir')
- op.add_option('--html-dir')
- op.add_option('--depth', type='int')
- op.add_option('--add-navigation', action='store_true')
- options, args = op.parse_args()
-
- if options.apidoc_dir:
- api_objects = get_api_objects(options.apidoc_dir)
- else:
- api_objects = {}
-
- for input_file in args:
- gendoc_html(input_file, options.html_dir, api_objects, options)
=======================================
--- /trunk/tools/gendoc_pdf.py Mon Jun 11 11:39:24 2012 UTC
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/env python
-
-'''Generate PDF documentation
-
-Requires docutils, docbook XSL stylesheets, xsltproc and Apache FOP (with
-Batik).
-'''
-
-__docformat__ = 'restructuredtext'
-__version__ = '$Id: gendoc_pdf.py 1950 2008-03-22 04:07:13Z Alex.Holkner $'
-
-import os
-import shutil
-import subprocess
-from xml.dom.minidom import parse
-
-from docutils.core import publish_doctree, publish_from_doctree
-from docutils.writers import docbook
-from docutils import nodes
-
-script_home = os.path.dirname(__file__)
-doc_root = os.path.join(script_home, '../doc')
-
-def get_docbook_path():
- '''Look up docbook URL in installed catalogs. If you don't use
catalogs,
- hack this function to return the complete path to your docbook dir.
- '''
- url = 'http://docbook.sourceforge.net/release/xsl/current/'
- if 'XML_CATALOG_FILES' in os.environ:
- catalogs = os.environ['XML_CATALOG_FILES'].split()
- for catalog in catalogs:
- proc = subprocess.Popen('xmlcatalog %s %s' % (catalog, url),
- shell=True,
- stdout=subprocess.PIPE)
- path = proc.communicate()[0]
- if proc.returncode == 0:
- return path.strip()
-
- raise "Docbook stylesheets not found... hack me with a path."
-
-def elements(node, name):
- '''Return all descendent element nodes of 'node' with given name'''
- matches = []
- if node.nodeType == node.ELEMENT_NODE and node.nodeName == name:
- matches = [node]
- for child in node.childNodes:
- matches += elements(child, name)
- return matches
-
-def rest2docbook(rest_filename, docbook_filename):
- print 'Reading %s' % rest_filename
-
- input_dir = os.path.dirname(rest_filename)
- output_dir = os.path.dirname(docbook_filename)
-
- # Read rest doctree
- doctree = publish_doctree(open(rest_filename).read(),
- source_path=rest_filename)
-
- # Remove fields (docbook writer ignores but warns)
- for field in [n for n in doctree.traverse() if isinstance(n,
nodes.field)]:
- field.parent.remove(field)
-
- # Remove line nodes (docbook crashes on them)
- for line in [n for n in doctree.traverse() if isinstance(n,
nodes.line)]:
- line.parent.replace(line, line.children)
-
- # Copy images
- for img in [n for n in doctree.traverse() if isinstance(n,
nodes.image)]:
- img['scale'] = '50'
- srcfile = os.path.join(input_dir, img['uri'])
- destfile = os.path.join(output_dir, img['uri'])
- shutil.copyfile(srcfile, destfile)
-
- print 'Writing %s' % docbook_filename
-
- # Write docbook xml
- writer = docbook.Writer()
- settings = {
- 'doctype': 'book',
- }
- docbook_xml = publish_from_doctree(doctree,
- writer=writer,
- settings_overrides=settings)
- open(docbook_filename, 'w').write(docbook_xml)
-
- # Open docbook xml and fix it
- print 'Reading %s' % docbook_filename
- doc = parse(docbook_filename)
-
- # Strip leading newline from programlisting
- for elem in elements(doc, 'programlisting'):
- if elem.childNodes and elem.childNodes[0].nodeType ==
elem.TEXT_NODE:
- elem.childNodes[0].nodeValue =
elem.childNodes[0].nodeValue.strip()
-
- # Dodgy hack to compensate for FOP's lack of table layout.
- # Programming guide tables need more room in the first (header) column
than
- # right-hand columns.
- for elem in elements(doc, 'colspec'):
- if elem.getAttribute('colname') == 'col_1':
- elem.attributes['colwidth'] = '2*'
- else:
- elem.attributes['colwidth'] = '1*'
-
- # Strip table of contents (docbook creates its own)
- for title in elements(doc, 'title'):
- if title.childNodes[0].nodeType == title.TEXT_NODE and \
- title.childNodes[0].nodeValue == 'Contents':
- section = title.parentNode
- if section.nodeType == section.ELEMENT_NODE and \
- section.nodeName == 'section':
- section.parentNode.removeChild(section)
-
- # Strip local contents
- for section in elements(doc, 'section'):
- for child in section.childNodes:
- if child.nodeType == child.ELEMENT_NODE:
- break
- if child.nodeName == 'itemizedlist':
- section.parentNode.removeChild(section)
-
- # Pull everything before first chapter into a preface
- preface_nodes = []
- preface = doc.createElement('preface')
- preface_title = doc.createElement('title')
- preface_title.appendChild(doc.createTextNode('Welcome'))
- preface.appendChild(preface_title)
- for child in doc.documentElement.childNodes:
- if child.nodeType == child.ELEMENT_NODE:
- if child.nodeName == 'chapter':
- for node in preface_nodes:
- doc.documentElement.removeChild(node)
- for node in preface_nodes:
- preface.appendChild(node)
- doc.documentElement.insertBefore(preface, child)
- break
- elif child.nodeName != 'bookinfo':
- preface_nodes.append(child)
-
- # Scale screenshots of windows down (programming guide hack to fit in
- # table)
- for imagedata in elements(doc, 'imagedata'):
- fileref = imagedata.getAttribute('fileref')
- if fileref.startswith('window_xp_') or
fileref.startswith('window_osx'):
- imagedata.attributes['scale'] = '25'
-
- # Write fixed docbook
- print 'Writing %s' % docbook_filename
- open(docbook_filename, 'w').write(doc.toxml())
-
-def docbook2pdf(docbook_filename, pdf_filename):
- # Run docbook FO stylesheet to produce XSL:FO document
- stylesheet = os.path.join(get_docbook_path(), 'fo/docbook.xsl')
- fo_filename = '%s.fo.xml' % os.path.splitext(docbook_filename)[0]
-
- print 'Using %s' % stylesheet
- print 'Writing %s' % fo_filename
- parameters = [
- #'--stringparam paper.type A4',
- #'--param double.sided 1',
- #'--stringparam alignment left',
- #'--param shade.verbatim 1',
- '--param chapter.autolabel 0',
- ]
- result = subprocess.call('xsltproc %s -o %s %s %s ' % (
- ' '.join(parameters), fo_filename, stylesheet, docbook_filename),
- shell=True)
-
- if result != 0:
- raise 'Aborting due to errors during docbook->FO conversion'
-
- print 'Writing %s' % pdf_filename
- subprocess.call('fop -fo %s -pdf %s' % (fo_filename, pdf_filename),
- shell=True)
-
-if __name__ == '__main__':
- try:
- os.makedirs(os.path.join(doc_root, 'pdf'))
- except OSError:
- pass
- try:
- os.makedirs(os.path.join(doc_root, 'docbook'))
- except OSError:
- pass
- rest2docbook(os.path.join(doc_root, 'programming_guide/index.txt'),
- os.path.join(doc_root, 'docbook/programming_guide.xml'))
- docbook2pdf(os.path.join(doc_root, 'docbook/programming_guide.xml'),
- os.path.join(doc_root, 'pdf/programming_guide.pdf'))
Reply all
Reply to author
Forward
0 new messages