Changeset 1367

Show
Ignore:
Timestamp:
09/28/08 16:25:21 (2 months ago)
Author:
ArcRiley
Message:

Ticket #964 :

  • basic Sphinx doc generation using Genshi templates
Location:
trunk/pysoy/docs
Files:
1 modified
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/pysoy/docs/__init__.py

    r1366 r1367  
    2121__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')' 
    2222 
    23 import sphinx 
     23import os 
     24import sphinx.application 
    2425import genshi.template 
    2526 
    26 class TemplateBridgeGenshi (sphinx.application.TemplateBridge) : 
     27class GenshiTemplateBridge (sphinx.application.TemplateBridge) : 
    2728  def init(self, builder) : 
    28     self.loader = genshi.template.TemplateLoader(builder.config.templates_path, 
    29                                                  auto_reload=True) 
     29    tmpl_path = [os.path.abspath(builder.config.templates_path[0])] 
     30    self.loader = genshi.template.TemplateLoader(tmpl_path, auto_reload=True) 
     31    if builder.name == 'html' : 
     32      self.method = 'html' 
     33    else : 
     34      self.method = 'unknown' 
     35 
    3036     
    31   #def newest_template_mtime(self) : 
     37  def newest_template_mtime(self) : 
     38    return 0 
     39 
    3240 
    3341  def render(self, template, context) : 
    3442    tmpl = self.loader.load(template) 
    35     return tmpl.generate(**context).render(method='html') 
     43    return tmpl.generate(**context).render(method=self.method).decode('utf-8') 
  • trunk/pysoy/docs/src/conf.py

    r1366 r1367  
    22import sys, os 
    33sys.path.append(os.path.abspath('../../')) 
     4import docs 
    45import config 
    56 
    67extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest'] 
    7 templates_path = ['../templates'] 
     8pygments_style = 'sphinx' 
     9templates_path = ['templates'] 
     10template_bridge = 'docs.GenshiTemplateBridge' 
    811source_suffix = '.rst' 
    912master_doc = 'index' 
     
    4144#show_authors = False 
    4245 
    43 # The name of the Pygments (syntax highlighting) style to use. 
    44 pygments_style = 'sphinx' 
    45  
    4646 
    4747# Options for HTML output 
    4848# ----------------------- 
    4949 
    50 # The style sheet to use for HTML and HTML Help pages. A file of that name 
    51 # must exist either in Sphinx' static/ path, or in one of the custom paths 
    52 # given in html_static_path. 
    5350html_style = 'default.css' 
    54  
    55 # The name for this set of Sphinx documents.  If None, it defaults to 
    56 # "<project> v<release> documentation". 
    57 #html_title = None 
    58  
    59 # A shorter title for the navigation bar.  Default is the same as html_title. 
    60 #html_short_title = None 
     51html_title = 'PySoy, a 3D Game Engine for Python' 
     52html_short_title = 'PySoy' 
    6153 
    6254# The name of an image file (within the static path) to place at the top of 
  • trunk/pysoy/docs/templates/page.html

    r1366 r1367  
    1 {%- block doctype -%} 
    2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    3   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    4 {%- endblock %} 
    5 {%- set reldelim1 = reldelim1 is not defined and ' &raquo;' or reldelim1 %} 
    6 {%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} 
    7 {%- macro relbar %} 
    8     <div class="related"> 
    9       <h3>Navigation</h3> 
    10       <ul> 
    11         {%- for rellink in rellinks %} 
    12         <li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}> 
    13           <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags }}" 
    14              accesskey="{{ rellink[2] }}">{{ rellink[3] }}</a> 
    15           {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li> 
    16         {%- endfor %} 
    17         {%- block rootrellink %} 
    18         <li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li> 
    19         {%- endblock %} 
    20         {%- for parent in parents %} 
    21           <li><a href="{{ parent.link|e }}" accesskey="U">{{ parent.title }}</a>{{ reldelim1 }}</li> 
    22         {%- endfor %} 
    23         {%- block relbaritems %}{% endblock %} 
    24       </ul> 
    25     </div> 
    26 {%- endmacro %} 
    27 {%- macro sidebar %} 
    28       {%- if builder != 'htmlhelp' %} 
    29       <div class="sphinxsidebar"> 
    30         <div class="sphinxsidebarwrapper"> 
    31           {%- block sidebarlogo %} 
    32           {%- if logo %} 
    33             <p class="logo"><img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/></p> 
    34           {%- endif %} 
    35           {%- endblock %} 
    36           {%- block sidebartoc %} 
    37           {%- if display_toc %} 
    38             <h3>Table Of Contents</h3> 
    39             {{ toc }} 
    40           {%- endif %} 
    41           {%- endblock %} 
    42           {%- block sidebarrel %} 
    43           {%- if prev %} 
    44             <h4>Previous topic</h4> 
    45             <p class="topless"><a href="{{ prev.link|e }}" title="previous chapter">{{ prev.title }}</a></p> 
    46           {%- endif %} 
    47           {%- if next %} 
    48             <h4>Next topic</h4> 
    49             <p class="topless"><a href="{{ next.link|e }}" title="next chapter">{{ next.title }}</a></p> 
    50           {%- endif %} 
    51           {%- endblock %} 
    52           {%- if sourcename %} 
    53             <h3>This Page</h3> 
    54             <ul class="this-page-menu"> 
    55             {%- if builder == 'web' %} 
    56               <li><a href="#comments">Comments ({{ comments|length }} so far)</a></li> 
    57               <li><a href="{{ pathto('@edit/' + sourcename)|e }}">Suggest Change</a></li> 
    58               <li><a href="{{ pathto('@source/' + sourcename)|e }}">Show Source</a></li> 
    59             {%- elif builder == 'html' %} 
    60               <li><a href="{{ pathto('_sources/' + sourcename, true)|e }}">Show Source</a></li> 
    61             {%- endif %} 
    62             </ul> 
    63           {%- endif %} 
    64           {%- if customsidebar %} 
    65           {{ rendertemplate(customsidebar) }} 
    66           {%- endif %} 
    67           {%- block sidebarsearch %} 
    68           {%- if pagename != "search" %} 
    69             <h3>{{ builder == 'web' and 'Keyword' or 'Quick' }} search</h3> 
    70             <form class="search" action="{{ pathto('search') }}" method="get"> 
    71               <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> 
    72               <input type="hidden" name="check_keywords" value="yes" /> 
    73               <input type="hidden" name="area" value="default" /> 
    74             </form> 
    75             {%- if builder == 'web' %} 
    76             <p style="font-size: 90%">Enter a module, class or function name.</p> 
    77             {%- endif %} 
    78           {%- endif %} 
    79           {%- endblock %} 
    80         </div> 
    81       </div> 
    82       {%- endif %} 
    83 {%- endmacro -%} 
    84  
    85 <html xmlns="http://www.w3.org/1999/xhtml"> 
     1<!DOCTYPE html 
     2    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
     3    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     4<html xmlns="http://www.w3.org/1999/xhtml" 
     5      xmlns:py="http://genshi.edgewall.org/" 
     6      xmlns:xi="http://www.w3.org/2001/XInclude" 
     7      lang="en"> 
    868  <head> 
    879    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    88     {%- if builder != 'htmlhelp' %} 
    89       {%- set titlesuffix = " &mdash; " + docstitle %} 
    90     {%- endif %} 
    91     <title>{{ title|striptags }}{{ titlesuffix }}</title> 
    92     {%- if builder == 'web' %} 
    93     <link rel="stylesheet" href="{{ pathto('index') }}?do=stylesheet{% 
    94       if in_admin_panel %}&admin=yes{% endif %}" type="text/css" /> 
    95     {%- for link, type, title in page_links %} 
    96     <link rel="alternate" type="{{ type|e(true) }}" title="{{ title|e(true) }}" href="{{ link|e(true) }}" /> 
    97     {%- endfor %} 
    98     {%- else %} 
    99     <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" /> 
    100     <link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" /> 
    101     {%- endif %} 
    102     {%- if builder != 'htmlhelp' %} 
    103     <script type="text/javascript"> 
    104       var DOCUMENTATION_OPTIONS = { 
    105           URL_ROOT:    '{{ pathto("", 1) }}', 
    106           VERSION:     '{{ release }}', 
    107           COLLAPSE_MODINDEX: false, 
    108           FILE_SUFFIX: '{{ file_suffix }}' 
    109       }; 
    110     </script> 
    111     <script type="text/javascript" src="{{ pathto('_static/jquery.js', 1) }}"></script> 
    112     <script type="text/javascript" src="{{ pathto('_static/interface.js', 1) }}"></script> 
    113     <script type="text/javascript" src="{{ pathto('_static/doctools.js', 1) }}"></script> 
    114     {%- if use_opensearch %} 
    115     <link rel="search" type="application/opensearchdescription+xml" 
    116           title="Search within {{ docstitle }}" 
    117           href="{{ pathto('_static/opensearch.xml', 1) }}"/> 
    118     {%- endif %} 
    119     {%- if favicon %} 
    120     <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/> 
    121     {%- endif %} 
    122     {%- endif %} 
    123 {%- block rellinks %} 
    124     {%- if hasdoc('about') %} 
    125     <link rel="author" title="About these documents" href="{{ pathto('about') }}" /> 
    126     {%- endif %} 
    127     <link rel="contents" title="Global table of contents" href="{{ pathto('contents') }}" /> 
    128     <link rel="index" title="Global index" href="{{ pathto('genindex') }}" /> 
    129     <link rel="search" title="Search" href="{{ pathto('search') }}" /> 
    130     {%- if hasdoc('copyright') %} 
    131     <link rel="copyright" title="Copyright" href="{{ pathto('copyright') }}" /> 
    132     {%- endif %} 
    133     <link rel="top" title="{{ docstitle }}" href="{{ pathto('index') }}" /> 
    134     {%- if parents %} 
    135     <link rel="up" title="{{ parents[-1].title|striptags }}" href="{{ parents[-1].link|e }}" /> 
    136     {%- endif %} 
    137     {%- if next %} 
    138     <link rel="next" title="{{ next.title|striptags }}" href="{{ next.link|e }}" /> 
    139     {%- endif %} 
    140     {%- if prev %} 
    141     <link rel="prev" title="{{ prev.title|striptags }}" href="{{ prev.link|e }}" /> 
    142     {%- endif %} 
    143 {%- endblock %} 
    144 {%- block extrahead %}{% endblock %} 
     10    <title>${pagename} - ${docstitle}</title> 
     11    <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> 
     12    <link rel="stylesheet" href="_static/${style}" type="text/css"  
     13     py:if="style" /> 
     14    <link rel="shortcut icon" href="_static/${favicon}" type="image/x-icon"  
     15     py:if="favicon" /> 
     16    <link rel="icon" href="_static/${favicon}" type="image/x-icon"  
     17     py:if="favicon" /> 
    14518  </head> 
    14619  <body> 
    147  
    148 {%- block relbar1 %}{{ relbar() }}{% endblock %} 
    149  
    150 {%- block sidebar1 %}{# possible location for sidebar #}{% endblock %} 
    151  
    152 {%- block document %} 
    153     <div class="document"> 
    154       <div class="documentwrapper"> 
    155       {%- if builder != 'htmlhelp' %} 
    156         <div class="bodywrapper"> 
    157       {%- endif %} 
    158           <div class="body"> 
    159             {% block body %}{% endblock %} 
    160           </div> 
    161       {%- if builder != 'htmlhelp' %} 
    162         </div> 
    163       {%- endif %} 
    164       </div> 
    165 {%- endblock %} 
    166  
    167 {%- block sidebar2 %}{{ sidebar() }}{% endblock %} 
    168       <div class="clearer"></div> 
    169     </div> 
    170  
    171 {%- block relbar2 %}{{ relbar() }}{% endblock %} 
    172  
    173 {%- block footer %} 
    174     <div class="footer"> 
    175     {%- if hasdoc('copyright') %} 
    176       <a href="{{ pathto('copyright') }}">Copyright</a> &copy; {{ copyright }} 
    177     {%- else %} 
    178       &copy; Copyright {{ copyright }}. 
    179     {%- endif %} 
    180     {%- if last_updated %} 
    181       Last updated on {{ last_updated }}. 
    182     {%- endif %} 
    183     {%- if show_sphinx %} 
    184       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>. 
    185     {%- endif %} 
    186     </div> 
    187 {%- endblock %} 
     20${Markup(body)} 
    18821  </body> 
    18922</html>