docutilsのnodesにノードを追加する
nodes._add_node_class_names("""index desc desc_content desc_signature
desc_type desc_returns desc_addname desc_name desc_parameterlist
desc_parameter desc_optional download_reference hlist hlistcol
centered versionmodified seealso productionlist production toctree
pending_xref compact_paragraph highlightlang literal_emphasis
abbreviation glossary acks module start_of_file tabular_col_spec
meta""".split())
sphinx-buildで呼ばれる。
app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
confoverrides, status, warning, freshenv,
warningiserror, tags)
app.build(force_all, filenames)
return app.statuscode
Sphinxはsphinx.applicationで定義されている
from sphinx.application import Sphinx
execfileの第二引数って何かな?と思ったので調べた
config = {}
execfile(config['__file__'], config)
execfile(...)
execfile(filename[, globals[, locals]])
Read and execute a Python script from a file.
The globals and locals are dictionaries, defaulting to the current
globals and locals. If only globals is given, locals defaults to it.
sphinxのエラークラスが記述されてる
glueらしいがよくわからん
builders/__init__.py
72: from sphinx.jinja2glue import BuiltinTemplateLoader
ext/autosummary/generate.py
30:from sphinx.jinja2glue import BuiltinTemplateLoader
jinja2glue.py
3: sphinx.jinja2glue
sphinx-quickstartコマンドの中身。Makefile等をここで作成している。
raw_inputで入力したデータをdecodeする流れは参考になる。
def do_prompt(d, key, text, default=None, validator=nonempty):
while True:
if default:
prompt = purple(PROMPT_PREFIX + '%s [%s]: ' % (text, default))
else:
prompt = purple(PROMPT_PREFIX + text + ': ')
x = raw_input(prompt)
if default and not x:
x = default
if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
if TERM_ENCODING:
x = x.decode(TERM_ENCODING)
else:
print turquoise('* Note: non-ASCII characters entered '
'and terminal encoding unknown -- assuming '
'UTF-8 or Latin-1.')
try:
x = x.decode('utf-8')
except UnicodeDecodeError:
x = x.decode('latin1')
try:
x = validator(x)
except ValidationError, err:
print red('* ' + str(err))
continue
break
d[key] = x
オフラインサーチ用
sphinxではリストを作るのに文字列をsplitするやり方を見ることが多い。 辞書順に並べておくと保守がやりやすいのかな?
stopwords = set("""
a and are as at
be but by
for
if in into is it
near no not
of on or
such
that the their then there these they this to
was will with
""".split())
Setuptools/distutils用のセットアップスクリプト cmdline.pyのsetuptool版