~openerp-chinese-team/openobject-doc/Chinese-init

« back to all changes in this revision

Viewing changes to i18n/zh_CN/source/conf.py

  • Committer: JoshuaJan
  • Date: 2012-12-04 01:36:44 UTC
  • Revision ID: popkar77@gmail.com-20121204013644-k25kpyac672wxe22
Chinese initialization

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
import sys, os
 
4
from docutils import nodes
 
5
 
 
6
# openobject-doc documentation build configuration file, created by
 
7
# sphinx-quickstart on Tue Dec  9 11:16:22 2008.
 
8
#
 
9
# This file is execfile()d with the current directory set to its containing dir.
 
10
#
 
11
# The contents of this file are pickled, so don't put values in the namespace
 
12
# that aren't pickleable (module imports are okay, they're removed automatically).
 
13
#
 
14
# All configuration values have a default; values that are commented out
 
15
# serve to show the default.
 
16
 
 
17
# If your extensions are in another directory, add it here. If the directory
 
18
# is relative to the documentation root, use os.path.abspath to make it
 
19
# absolute, like shown here.
 
20
 
 
21
# WARNING: if you want to generate the OpenERP ORM docstrings
 
22
# you need to make sure that OpenERP server is in the python path
 
23
# by setting a PYTHONPATH environment variable containing the path
 
24
# to the server's 'bin' directory, or by explicitly adding it below.
 
25
# sys.path.append(os.path.abspath('.'))
 
26
 
 
27
# General configuration
 
28
# ---------------------
 
29
 
 
30
# Add any Sphinx extension module names here, as strings. They can be extensions
 
31
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 
32
extensions = [
 
33
  'sphinx.ext.todo',
 
34
  'sphinx.ext.ifconfig',
 
35
  'sphinx.ext.autodoc'
 
36
]
 
37
todo_include_todos = False
 
38
 
 
39
# Add any paths that contain templates here, relative to this directory.
 
40
templates_path = ['.templates']
 
41
 
 
42
# The suffix of source filenames.
 
43
source_suffix = '.rst'
 
44
 
 
45
# The encoding of source files.
 
46
#source_encoding = 'utf-8'
 
47
 
 
48
# The master toctree document.
 
49
master_doc = 'index'
 
50
 
 
51
# The version info for the project you're documenting, acts as replacement for
 
52
# |version| and |release|, also used in various other places throughout the
 
53
# built documents.
 
54
#
 
55
# The short X.Y version.
 
56
# version = '1.0'
 
57
# The full version, including alpha/beta/rc tags.
 
58
release = '6.0.0'
 
59
 
 
60
# The language for content autogenerated by Sphinx. Refer to documentation
 
61
# for a list of supported languages.
 
62
#language = None
 
63
 
 
64
# There are two options for replacing |today|: either, you set today to some
 
65
# non-false value, then it is used:
 
66
#today = ''
 
67
# Else, today_fmt is used as the format for a strftime call.
 
68
today_fmt = '%Y-%m-%d'
 
69
 
 
70
# List of documents that shouldn't be included in the build.
 
71
unused_docs = [
 
72
  'contribute/10_irc_meeting', #Out of date? IRC meetings not held anymore?
 
73
  'contribute/summary_of_ressources',
 
74
  'customize/index', #empty
 
75
  'developer/17_Web_services/index', #Should be merged with 6_21_web_services?
 
76
  'developer/7_School/index',
 
77
  'features/example',
 
78
  'features/repairs',
 
79
  'install/windows/allinone',
 
80
]
 
81
 
 
82
# List of directories, relative to source directory, that shouldn't be searched
 
83
# for source files.
 
84
exclude_trees = [
 
85
   #'bi',
 
86
   #'book',
 
87
   #'customize',
 
88
   #'install',
 
89
   #'contribute',
 
90
   #'developer',
 
91
   #'features',
 
92
   #'exercice',
 
93
   #'technical_guide',
 
94
   'verticalisations',
 
95
   'developer/old_dev', # Tmp fix while refactoring dev book
 
96
]
 
97
 
 
98
# The reST default role (used for this markup: `text`) to use for all documents.
 
99
#default_role = None
 
100
 
 
101
# If true, '()' will be appended to :func: etc. cross-reference text.
 
102
#add_function_parentheses = True
 
103
 
 
104
# If true, the current module name will be prepended to all description
 
105
# unit titles (such as .. function::).
 
106
#add_module_names = True
 
107
 
 
108
# If true, sectionauthor and moduleauthor directives will be shown in the
 
109
# output. They are ignored by default.
 
110
#show_authors = False
 
111
 
 
112
# The name of the Pygments (syntax highlighting) style to use.
 
113
pygments_style = 'sphinx'
 
114
 
 
115
# Options for HTML output
 
116
# -----------------------
 
117
 
 
118
# The style sheet to use for HTML and HTML Help pages. A file of that name
 
119
# must exist either in Sphinx' static/ path, or in one of the custom paths
 
120
# given in html_static_path.
 
121
html_style = 'default.css'
 
122
 
 
123
# The name for this set of Sphinx documents.  If None, it defaults to
 
124
# "<project> v<release> documentation".
 
125
html_title = 'OpenERP v6'
 
126
 
 
127
# A shorter title for the navigation bar.  Default is the same as html_title.
 
128
#html_short_title = None
 
129
 
 
130
# The name of an image file (relative to this directory) to place at the top
 
131
# of the sidebar.
 
132
 
 
133
html_logo = None
 
134
 
 
135
# The name of an image file (within the static path) to use as favicon of the
 
136
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
 
137
# pixels large.
 
138
html_favicon = 'favicon.ico'
 
139
 
 
140
# Add any paths that contain custom static files (such as style sheets) here,
 
141
# relative to this directory. They are copied after the builtin static files,
 
142
# so a file named "default.css" will overwrite the builtin "default.css".
 
143
html_static_path = ['.static']
 
144
 
 
145
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 
146
# using the given strftime format.
 
147
html_last_updated_fmt = '%Y-%m-%d'
 
148
 
 
149
# If true, SmartyPants will be used to convert quotes and dashes to
 
150
# typographically correct entities.
 
151
#html_use_smartypants = True
 
152
 
 
153
# Custom sidebar templates, maps document names to template names.
 
154
#html_sidebars = {}
 
155
 
 
156
# Additional templates that should be rendered to pages, maps page names to
 
157
# template names.
 
158
#html_additional_pages = {}
 
159
 
 
160
# If false, no module index is generated.
 
161
#html_use_modindex = True
 
162
 
 
163
# If false, no index is generated.
 
164
#html_use_index = True
 
165
 
 
166
# If true, the index is split into individual pages for each letter.
 
167
#html_split_index = False
 
168
 
 
169
# If true, the reST sources are included in the HTML build as _sources/<name>.
 
170
html_copy_source = True
 
171
 
 
172
# If true, an OpenSearch description file will be output, and all pages will
 
173
# contain a <link> tag referring to it.  The value of this option must be the
 
174
# base URL from which the finished HTML is served.
 
175
#html_use_opensearch = ''
 
176
 
 
177
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
 
178
#html_file_suffix = ''
 
179
 
 
180
# Output file base name for HTML help builder.
 
181
htmlhelp_basename = 'openobject-doc'
 
182
 
 
183
 
 
184
# Options for LaTeX output
 
185
# ------------------------
 
186
 
 
187
# The paper size ('letter' or 'a4').
 
188
latex_paper_size = 'a4'
 
189
 
 
190
# The font size ('10pt', '11pt' or '12pt').
 
191
latex_font_size = '9pt'
 
192
 
 
193
# Grouping the document tree into LaTeX files. List of tuples
 
194
# (source start file, target name, title, author, document class [howto/manual]).
 
195
#latex_documents = [
 
196
#  ('index', 'openobject-doc.tex', ur'openobject Documentation',
 
197
#   ur'OpenObject Community', 'manual'),
 
198
#]
 
199
 
 
200
latex_documents = [
 
201
   ('book/index', 'openerp-book.tex', ur'Open ERP, a modern approach to integrated business management', ur'Fabien Pinckaers\\Geoff Gardiner\\Els Van Vossel', 'manual'),
 
202
   #('bi/index', 'openobject-bi.tex', ur'Open Object Business Intelligence', ur'OpenERP SA', 'manual'),
 
203
   #('customize', 'openobject-customize.tex', ur'Open Object Customization Book', ur'OpenERP SA', 'manual'),
 
204
   ('install/index', 'openobject-install.tex', ur'Open Object Installation Manuals', ur'OpenERP SA', 'manual'),
 
205
   #('contribute/index', 'openobject-contribute.tex', ur'Open Object Community Book', ur'OpenERP SA', 'manual'),
 
206
   ('developer/index', 'openobject-developer.tex', ur'Open Object Developer Book', ur'OpenERP SA', 'manual'),
 
207
   #('features/index', 'openobject-features.tex', ur'Open ERP Features', ur'OpenERP SA', 'manual'),
 
208
   #('verticalisations', 'openobject-verticalisations.tex', ur'Open Object verticalisations', ur'OpenERP SA', 'manual'),
 
209
   ('technical_guide/index', 'openobject-technical_guide.tex', ur'Open Object Technical Guide', ur'OpenERP SA', 'manual'),
 
210
   ('training_material/user_training/v5/exercises/index', 'openerp-user-training-v5-exercises.tex', ur'User Training - Exercises', ur'OpenERP', 'howto'),
 
211
   ('training_material/user_training/v5/solutions/index', 'openerp-user-training-v5-solutions.tex', ur'User Training - Solutions', ur'OpenERP', 'howto'),
 
212
   #('training_material/user_training/v6/exercises/index', 'openerp-user-training-v6-exercises.tex', ur'User Training - Exercises', ur'OpenERP', 'howto'),
 
213
   #('training_material/user_training/v6/solutions/index', 'openerp-user-training-v6-solutions.tex', ur'User Training - Solutions', ur'OpenERP', 'howto'),
 
214
   #('training_material/technical_training/v5/exercises/index', 'openerp-technical-training-v5-exercises.tex', ur'Technical Training - Exercises', ur'OpenERP', 'howto'),
 
215
   #('training_material/technical_training/v5/solutions/index', 'openerp-technical-training-v5-solutions.tex', ur'Technical Training - Solutions', ur'OpenERP', 'howto'),
 
216
]
 
217
 
 
218
# The name of an image file (relative to this directory) to place at the top of
 
219
# the title page.
 
220
latex_logo = '.static/openerp.jpg'
 
221
 
 
222
# For "manual" documents, if this is true, then toplevel headings are parts,
 
223
# not chapters.
 
224
latex_use_parts = True
 
225
 
 
226
# Additional stuff for the LaTeX preamble.
 
227
#latex_preamble = '' # DEPRECATED sinc sphinx 0.5 (use 'latex_elements')
 
228
 
 
229
tiny_latex_include = r"""
 
230
\usepackage{flowfram}
 
231
 
 
232
\DeclareUnicodeCharacter{00A0}{~}
 
233
 
 
234
\definecolor{MyGray}{rgb}{0.80,0.80,0.80}
 
235
 
 
236
\makeatletter\newenvironment{graybox}{%
 
237
   \begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}}{\end{minipage}\end{lrbox}%
 
238
   \colorbox{MyGray}{\usebox{\@tempboxa}}
 
239
}\makeatother
 
240
 
 
241
\makeatletter
 
242
\renewenvironment{notice}[2]{
 
243
  \begin{graybox}
 
244
  \bf\it
 
245
  \def\py@noticetype{#1}
 
246
  \par\strong{#2}
 
247
  \csname py@noticestart@#1\endcsname
 
248
}
 
249
{
 
250
  \csname py@noticeend@\py@noticetype\endcsname
 
251
  \end{graybox}
 
252
}
 
253
\makeatother
 
254
 
 
255
\renewenvironment{figure}[6]{
 
256
  \begin{staticfigure}
 
257
}{
 
258
  \end{staticfigure}
 
259
}
 
260
 
 
261
%% Stupid workaround for stuff that is defined in howto.cls but
 
262
%% overwritten by sphinx.sty!!
 
263
 
 
264
\makeatletter
 
265
%\let\py@OldTableofcontents=\tableofcontents
 
266
\renewcommand{\tableofcontents}{
 
267
  \begingroup
 
268
    \parskip = 0mm
 
269
    \py@OldTableofcontents
 
270
  \endgroup
 
271
  \newpage
 
272
  %\rule{\textwidth}{1pt}
 
273
  %\vspace{12pt}
 
274
}
 
275
\makeatother
 
276
 
 
277
\pagestyle{plain}
 
278
\pagenumbering{arabic}
 
279
\thispagestyle{empty}
 
280
 
 
281
"""
 
282
 
 
283
latex_elements = {
 
284
    'preamble': tiny_latex_include,
 
285
    'papersize': 'a4paper',
 
286
}
 
287
 
 
288
# Documents to append as an appendix to all manuals.
 
289
#latex_appendices = ['doc_copyright.rst']
 
290
 
 
291
# If false, no module index is generated.
 
292
#latex_use_modindex = True
 
293
 
 
294
def end_foreword_directive(name, arguments, options, content, lineno,
 
295
                           content_offset, block_text, state, state_machine):
 
296
    return [nodes.Text('')]
 
297
 
 
298
def begin_conclusion_directive(name, arguments, options, content, lineno,
 
299
                               content_offset, block_text, state, state_machine):
 
300
    return [nodes.Text('')]
 
301
 
 
302
# add js-kit comments or not
 
303
# Disabled by ODO on 2012-10-22 as Echo service as been discontinued, and comments
 
304
# were rarely useful anyhow
 
305
js_kit_comments = False
 
306
 
 
307
def setup(app):
 
308
    from sphinx import __version__
 
309
    revisions = map(lambda x: x.isdigit() and int(x) or 0, __version__.split('.'))
 
310
    major, minor = revisions[0], revisions[1]
 
311
    if major*10+minor < 6:
 
312
        raise Exception("You should upgrade Sphinx to version 0.6 or higher")
 
313
 
 
314
    from sphinx.writers.html import HTMLTranslator, BaseTranslator
 
315
    import pickle
 
316
 
 
317
    # load unique_path dict:
 
318
    comments_path_pickle_filename = "comments_path.pickle"
 
319
    if os.path.exists(comments_path_pickle_filename):
 
320
        comments_path_pickle_file = open(comments_path_pickle_filename, 'r')
 
321
        comments_path_dict = pickle.load(comments_path_pickle_file)
 
322
        comments_path_pickle_file.close()
 
323
    else:
 
324
        comments_path_dict = {}
 
325
    this_build_comments_path_dict = {}
 
326
 
 
327
    def save_comments_path_dict():
 
328
        comments_path_pickle_file = open(comments_path_pickle_filename, 'w')
 
329
        pickle.dump(comments_path_dict, comments_path_pickle_file)
 
330
        comments_path_pickle_file.close()
 
331
 
 
332
    import atexit
 
333
    atexit.register(save_comments_path_dict)
 
334
 
 
335
    def depart_title_new(self, node):
 
336
        res = old_depart_title(self, node) # call the original depart_title.
 
337
 
 
338
        if self.builder.globalcontext.get('builder') == 'html':
 
339
            parent_class_name = node.parent.__class__.__name__
 
340
            if parent_class_name == 'section' and self.section_level == 2:
 
341
                title_id = "/" + node.parent.attributes['ids'][0]
 
342
                link_anchor = "#" + node.parent.attributes['ids'][0]
 
343
                ## paths should be unique:
 
344
                ## -> build a database (pickled dict) with already used paths and
 
345
                ## create a new unique path if already used.
 
346
                title_path = self.document['source']
 
347
                path_start = title_path.find('%ssource%s' % (os.sep, os.sep))
 
348
                title_path = title_path[path_start+8:].replace('.rst', '')
 
349
 
 
350
                if title_id not in this_build_comments_path_dict: # first time we process this path
 
351
                    title_id = comments_path_dict.get(title_id, title_id)
 
352
                    this_build_comments_path_dict[title_id] = title_id
 
353
                    comments_path_dict[title_id] = title_id
 
354
                else: # it's a double
 
355
                    title_id = u"""/%s%s""" % (title_path, title_id, )
 
356
                    this_build_comments_path_dict[title_id] = title_id
 
357
                    comments_path_dict[title_id] = title_id
 
358
 
 
359
                # we need a uniq attribute that never changes, but the permalink will be computed after rendering
 
360
                # the page so we can figure out the final URL, up to the correct anchor (Echo generates a default
 
361
                # permalink using the document.location if it's missing, but that will cause twitter post etc. to
 
362
                # appear on each section, as it is not able to distinguish sections on the same page!
 
363
                # See http://wiki.js-kit.com/Echo+-+Install+-+A+custom+website#Settinguptheuniqandpermalinkattributes
 
364
                # See the runtime computation in source/.templates/layout.html
 
365
                self.body.append(u"""<div class="js-kit-comments" uniq="%s" permalink_anchor="%s" ></div>""" % (title_id, link_anchor))
 
366
 
 
367
        return res
 
368
 
 
369
    if js_kit_comments:
 
370
        old_depart_title = HTMLTranslator.depart_title
 
371
        HTMLTranslator.depart_title = depart_title_new
 
372
 
 
373
    app.add_directive('end_foreword', end_foreword_directive, 1, (0, 0, 0))
 
374
    app.add_directive('begin_conclusion', begin_conclusion_directive, 1, (0, 0, 0))
 
375