recreate the directory tree
|
@ -0,0 +1,130 @@
|
|||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = build
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
-rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sphinxdoc.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sphinxdoc.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/sphinxdoc"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sphinxdoc"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
make -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
11
README.rst
|
@ -41,7 +41,7 @@ nginx由于出色的性能,在世界范围内受到了越来越多人的关注
|
|||
2012/11/24|更新第2章(ngx_buf_t的部分字段以及其他一些书写错误和表达)
|
||||
2012/12/18|更新第11章(解析http块)
|
||||
2012/12/10|增加第3章的内容
|
||||
2012/12/28|补充和完善了第3章的内容
|
||||
2012/12/28|补充和完善了第3章的内容
|
||||
|
||||
版权申明
|
||||
++++++++++++
|
||||
|
@ -61,14 +61,7 @@ nginx由于出色的性能,在世界范围内受到了越来越多人的关注
|
|||
目录
|
||||
++++++
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
module_development.rst
|
||||
source_analysis.rst
|
||||
appendix_a.rst
|
||||
appendix_b.rst
|
||||
appendix_c.rst
|
||||
书籍浏览 (http://tengine.taobao.org/book/index.html)
|
||||
|
||||
团队成员
|
||||
++++++++++++
|
||||
|
|
207
example_1.rst
|
@ -1,207 +0,0 @@
|
|||
模块开发
|
||||
============
|
||||
|
||||
upstream模块
|
||||
------------
|
||||
|
||||
nginx模块一般被分成三大类:handler、filter和upstream。前面的章节中,读者已经了解了handler、filter。利用这两类模块,可以使nginx轻松完成任何单机工作。而本章介绍的upstream,将使nginx将跨越单机的限制,完成网络数据的接收、处理和转发。
|
||||
|
||||
数据转发功能,为nginx提供了跨越单机的横向处理能力,使nginx摆脱只能为终端节点提供单一功能的限制,而使它具备了网路应用级别的拆分、封装和整合的战略功能。在云模型大行其道的今天,数据转发使nginx有能力构建一个网络应用的关键组件。当然,一个网络应用的关键组件往往一开始都会考虑通过高级开发语言编写,因为开发比较方便,但系统到达一定规模,需要更重视性能的时候,这些高级语言为了达成目标所做的结构化修改所付出的代价会使nginx的upstream模块就呈现出极大的吸引力,因为他天生就快。作为附带,nginx的配置提供的层次化和松耦合使得系统的扩展性也可能达到比较高的程度。
|
||||
|
||||
言归正传,下面介绍upstream的写法。
|
||||
|
||||
upstream模块接口
|
||||
+++++++++++++++++++
|
||||
|
||||
从本质上说,upstream属于handler,只是他不产生自己的内容,而是通过请求后端服务器得到内容,所以才称为upstream(上游)。请求并取得响应内容的整个过程已经被封装到nginx内部,所以upstream模块只需要开发若干回调函数,完成构造请求和解析响应等具体的工作。
|
||||
|
||||
这些回调函数如下表所示:
|
||||
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|create_request |生成发送到后端服务器的请求缓冲(缓冲链)。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|reinit_request |在某台后端服务器出错的情况,nginx会尝试另一台后端服务器。 |
|
||||
| |nginx选定新的服务器以后,会先调用此函数,然后再次调用 |
|
||||
| |create_request,以重新初始化upstream模块的工作状态。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|process_header |处理后端服务器返回的信息头部。所谓头部是与upstream server |
|
||||
| |通信的协议规定的,比如HTTP协议的header部分,或者memcached |
|
||||
| |协议的响应状态部分。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|abort_request |在客户端放弃请求时被调用。不需要在函数中实现关闭后端服务 |
|
||||
| |器连接的功能,系统会自动完成关闭连接的步骤,所以一般此函 |
|
||||
| |数不会进行任何具体工作。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|finalize_request |正常完成与后端服务器的请求后调用该函数,与abort_request |
|
||||
| |相同,一般也不会进行任何具体工作。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|input_filter |处理后端服务器返回的响应正文。nginx默认的input_filter会 |
|
||||
| |将收到的内容封装成为缓冲区链ngx_chain。该链由upstream的 |
|
||||
| |out_bufs指针域定位,所以开发人员可以在模块以外通过该指针 |
|
||||
| |得到后端服务器返回的正文数据。memcached模块实现了自己的 |
|
||||
| |input_filter,在后面会具体分析这个模块。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|input_filter_init |初始化input filter的上下文。nginx默认的input_filter_init |
|
||||
| |直接返回。 |
|
||||
+-------------------+--------------------------------------------------------------+
|
||||
|
||||
memcached模块分析
|
||||
++++++++++++++++++++++++++++++
|
||||
|
||||
memcache是一款高性能的分布式cache系统,得到了非常广泛的应用。memcache定义了一套私有通信协议,使得不能通过HTTP请求来访问memcache。但协议本身简单高效,而且memcache使用广泛,所以大部分现代开发语言和平台都提供了memcache支持,方便开发者使用memcache。
|
||||
|
||||
nginx提供了ngx_http_memcached模块,提供从memcache读取数据的功能,而不提供向memcache写数据的功能。作为web服务器,这种设计是可以接受的。
|
||||
|
||||
下面,我们开始分析ngx_http_memcached模块,一窥upstream的奥秘。
|
||||
|
||||
Handler模块?
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
初看memcached模块,大家可能觉得并无特别之处。如果稍微细看,甚至觉得有点像handler模块,当大家看到这段代码以后,必定疑惑为什么会跟handler模块一模一样。
|
||||
|
||||
.. code:: c
|
||||
|
||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||
clcf->handler = ngx_http_memcached_handler;
|
||||
|
||||
因为upstream模块使用的就是handler模块的接入方式。同时,upstream模块的指令系统的设计也是遵循handler模块的基本规则:配置该模块才会执行该模块。
|
||||
|
||||
.. code:: c
|
||||
|
||||
{ ngx_string("memcached_pass"),
|
||||
NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
|
||||
ngx_http_memcached_pass,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
0,
|
||||
NULL }
|
||||
|
||||
所以大家觉得眼熟是好事,说明大家对Handler的写法已经很熟悉了。
|
||||
|
||||
Upstream模块!
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
那么,upstream模块的特别之处究竟在哪里呢?答案是就在模块处理函数的实现中。upstream模块的处理函数进行的操作都包含一个固定的流程。在memcached的例子中,可以观察ngx_http_memcached_handler的代码,可以发现,这个固定的操作流程是:
|
||||
|
||||
1\. 创建upstream数据结构。
|
||||
|
||||
.. code:: c
|
||||
|
||||
if (ngx_http_upstream_create(r) != NGX_OK) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
2\. 设置模块的tag和schema。schema现在只会用于日志,tag会用于buf_chain管理。
|
||||
|
||||
.. code:: c
|
||||
|
||||
u = r->upstream;
|
||||
|
||||
ngx_str_set(&u->schema, "memcached://");
|
||||
u->output.tag = (ngx_buf_tag_t) &ngx_http_memcached_module;
|
||||
|
||||
3\. 设置upstream的后端服务器列表数据结构。
|
||||
|
||||
.. code:: c
|
||||
|
||||
mlcf = ngx_http_get_module_loc_conf(r, ngx_http_memcached_module);
|
||||
u->conf = &mlcf->upstream;
|
||||
|
||||
4\. 设置upstream回调函数。在这里列出的代码稍稍调整了代码顺序。
|
||||
|
||||
.. code:: c
|
||||
|
||||
u->create_request = ngx_http_memcached_create_request;
|
||||
u->reinit_request = ngx_http_memcached_reinit_request;
|
||||
u->process_header = ngx_http_memcached_process_header;
|
||||
u->abort_request = ngx_http_memcached_abort_request;
|
||||
u->finalize_request = ngx_http_memcached_finalize_request;
|
||||
u->input_filter_init = ngx_http_memcached_filter_init;
|
||||
u->input_filter = ngx_http_memcached_filter;
|
||||
|
||||
5\. 创建并设置upstream环境数据结构。
|
||||
|
||||
.. code:: c
|
||||
|
||||
ctx = ngx_palloc(r->pool, sizeof(ngx_http_memcached_ctx_t));
|
||||
if (ctx == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
ctx->rest = NGX_HTTP_MEMCACHED_END;
|
||||
ctx->request = r;
|
||||
|
||||
ngx_http_set_ctx(r, ctx, ngx_http_memcached_module);
|
||||
|
||||
u->input_filter_ctx = ctx;
|
||||
|
||||
6\. 完成upstream初始化并进行收尾工作。
|
||||
|
||||
.. code:: c
|
||||
|
||||
r->main->count++;
|
||||
ngx_http_upstream_init(r);
|
||||
return NGX_DONE;
|
||||
|
||||
任何upstream模块,简单如memcached,复杂如proxy、fastcgi都是如此。不同的upstream模块在这6步中的最大差别会出现在第2、3、4、5上。其中第2、4两步很容易理解,不同的模块设置的标志和使用的回调函数肯定不同。第5步也不难理解,只有第3步是最为晦涩的,不同的模块在取得后端服务器列表时,策略的差异非常大,有如memcached这样简单明了的,也有如proxy那样逻辑复杂的。这个问题先记下来,等把memcached剖析清楚了,再单独讨论。
|
||||
|
||||
第6步是一个常态。将count加1,然后返回NGX_DONE。nginx遇到这种情况,虽然会认为当前请求的处理已经结束,但是不会释放请求使用的内存资源,也不会关闭与客户端的连接。之所以需要这样,是因为nginx建立了upstream请求和客户端请求之间一对一的关系,在后续使用ngx_event_pipe将upstream响应发送回客户端时,还要使用到这些保存着客户端信息的数据结构。这部分会在后面的原理篇做具体介绍,这里不再展开。
|
||||
|
||||
将upstream请求和客户端请求进行一对一绑定,这个设计有优势也有缺陷。优势就是简化模块开发,可以将精力集中在模块逻辑上,而缺陷同样明显,一对一的设计很多时候都不能满足复杂逻辑的需要。对于这一点,将会在后面的原理篇来阐述。
|
||||
|
||||
|
||||
回调函数
|
||||
^^^^^^^^^^^
|
||||
|
||||
前面剖析了memcached模块的骨架,现在开始逐个解决每个回调函数。
|
||||
|
||||
1\. ngx_http_memcached_create_request:很简单的按照设置的内容生成一个key,接着生成一个“get $key”的请求,放在r->upstream->request_bufs里面。
|
||||
|
||||
2\. ngx_http_memcached_reinit_request:无需初始化。
|
||||
|
||||
3\. ngx_http_memcached_abort_request:无需额外操作。
|
||||
|
||||
4\. ngx_http_memcached_finalize_request:无需额外操作。
|
||||
|
||||
5\. ngx_http_memcached_process_header:模块的业务重点函数。memcache协议将头部信息被定义为第一行文本,可以找到这段代码证明:
|
||||
|
||||
.. code:: c
|
||||
|
||||
for (p = u->buffer.pos; p < u->buffer.last; p++) {
|
||||
if ( * p == LF) {
|
||||
goto found;
|
||||
}
|
||||
|
||||
如果在已读入缓冲的数据中没有发现LF('\n')字符,函数返回NGX_AGAIN,表示头部未完全读入,需要继续读取数据。nginx在收到新的数据以后会再次调用该函数。
|
||||
|
||||
nginx处理后端服务器的响应头时只会使用一块缓存,所有数据都在这块缓存中,所以解析头部信息时不需要考虑头部信息跨越多块缓存的情况。而如果头部过大,不能保存在这块缓存中,nginx会返回错误信息给客户端,并记录error log,提示缓存不够大。
|
||||
|
||||
process_header的重要职责是将后端服务器返回的状态翻译成返回给客户端的状态。例如,在ngx_http_memcached_process_header中,有这样几段代码:
|
||||
|
||||
.. code:: c
|
||||
|
||||
r->headers_out.content_length_n = ngx_atoof(len, p - len - 1);
|
||||
|
||||
u->headers_in.status_n = 200;
|
||||
u->state->status = 200;
|
||||
|
||||
u->headers_in.status_n = 404;
|
||||
u->state->status = 404;
|
||||
|
||||
u->state用于计算upstream相关的变量。比如u->status->status将被用于计算变量“upstream_status”的值。u->headers_in将被作为返回给客户端的响应返回状态码。而第一行则是设置返回给客户端的响应的长度。
|
||||
|
||||
在这个函数中不能忘记的一件事情是处理完头部信息以后需要将读指针pos后移,否则这段数据也将被复制到返回给客户端的响应的正文中,进而导致正文内容不正确。
|
||||
|
||||
.. code:: c
|
||||
|
||||
u->buffer.pos = p + 1;
|
||||
|
||||
process_header函数完成响应头的正确处理,应该返回NGX_OK。如果返回NGX_AGAIN,表示未读取完整数据,需要从后端服务器继续读取数据。返回NGX_DECLINED无意义,其他任何返回值都被认为是出错状态,nginx将结束upstream请求并返回错误信息。
|
||||
|
||||
6\. ngx_http_memcached_filter_init:修正从后端服务器收到的内容长度。因为在处理header时没有加上这部分长度。
|
||||
|
||||
7\. ngx_http_memcached_filter:memcached模块是少有的带有处理正文的回调函数的模块。因为memcached模块需要过滤正文末尾CRLF "END" CRLF,所以实现了自己的filter回调函数。处理正文的实际意义是将从后端服务器收到的正文有效内容封装成ngx_chain_t,并加在u->out_bufs末尾。nginx并不进行数据拷贝,而是建立ngx_buf_t数据结构指向这些数据内存区,然后由ngx_chain_t组织这些buf。这种实现避免了内存大量搬迁,也是nginx高效的奥秘之一。
|
||||
|
||||
本节小结
|
||||
++++++++++++
|
||||
|
||||
在这一节里,大家对upstream模块的基本组成有了一些认识。upstream模块是从handler模块发展而来,指令系统和模块生效方式与handler模块无异。不同之处在于,upstream模块在handler函数中设置众多回调函数。实际工作都是由这些回调函数完成的。每个回调函数都是在upstream的某个固定阶段执行,各司其职,大部分回调函数一般不会真正用到。upstream最重要的回调函数是create_request、process_header和input_filter,他们共同实现了与后端服务器的协议的解析部分。
|
|
@ -1,2 +0,0 @@
|
|||
源码解析
|
||||
==========
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sphinx
|
||||
|
||||
def setup(app):
|
||||
app.add_javascript('booktools.js')
|
|
@ -0,0 +1,79 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from sphinx.util.compat import Directive
|
||||
import shutil
|
||||
import pdb
|
||||
import os.path as path
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils import nodes
|
||||
|
||||
def build_finished(app, ex):
|
||||
if app.builder.name == "latex":
|
||||
import glob
|
||||
curpath = path.split(__file__)[0]
|
||||
for fn in glob.glob(path.join(curpath, "latexstyle", "*.*")):
|
||||
print "copy %s" % fn
|
||||
shutil.copy(fn, path.join(app.builder.outdir, path.split(fn)[-1]))
|
||||
|
||||
class timgblock(nodes.Part, nodes.Element):
|
||||
pass
|
||||
|
||||
def latex_visit_timgblock(self, node):
|
||||
text = r"""
|
||||
\framebox[1.0 \textwidth]{
|
||||
\includegraphics[width=2.5em]{%(image)s.pdf}
|
||||
\raisebox{1.0em}{\parbox{0.9 \textwidth}{\small
|
||||
"""
|
||||
self.body.append( text % node)
|
||||
self.context.append("}}}")
|
||||
|
||||
def latex_depart_timgblock(self, node):
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
def html_visit_timgblock(self, node):
|
||||
text = r"""<div class="imagebox" style="background-image: url(_static/%(image)s.png)">"""
|
||||
self.body.append(text % node)
|
||||
self.context.append("</div>")
|
||||
|
||||
def html_depart_timgblock(self, node):
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
def empty_visit(self, node):
|
||||
raise nodes.SkipNode
|
||||
|
||||
class ImageBlockDirective(Directive):
|
||||
has_content = True
|
||||
required_arguments = 0
|
||||
optional_arguments = 2
|
||||
final_argument_whitespace = True
|
||||
option_spec = {
|
||||
'text': directives.unchanged
|
||||
}
|
||||
image = ""
|
||||
|
||||
def run(self):
|
||||
node = timgblock()
|
||||
node["image"] = self.image
|
||||
if self.arguments and self.arguments[0]:
|
||||
node['argument'] = u" ".join(self.arguments)
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
ret = [node]
|
||||
return ret
|
||||
|
||||
def MakeFileDirective(imgname):
|
||||
#curpath = path.split(__file__)[0]
|
||||
#shutil.copy(path.join(curpath, imgname + ".pdf"), path.join(curpath, "..\\..\\build\\latex"))
|
||||
return type(imgname+"Directive",(ImageBlockDirective,),{"image":imgname})
|
||||
|
||||
def setup(app):
|
||||
#pdb.set_trace()
|
||||
app.add_node(timgblock,
|
||||
latex=(latex_visit_timgblock, latex_depart_timgblock),
|
||||
text=(empty_visit, None),
|
||||
html=(html_visit_timgblock, html_depart_timgblock))
|
||||
app.add_directive('tcode', MakeFileDirective("code"))
|
||||
app.add_directive('tanim', MakeFileDirective("anim"))
|
||||
app.add_directive('twarning', MakeFileDirective("warning"))
|
||||
app.add_directive('tlink', MakeFileDirective("link"))
|
||||
app.add_directive('ttip', MakeFileDirective("tip"))
|
||||
app.add_directive('tthink', MakeFileDirective("think"))
|
||||
app.connect("build-finished", build_finished)
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
def setup(app):
|
||||
import sphinx.search as search
|
||||
import zh
|
||||
search.languages["zh_CN"] = zh.SearchChinese
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from docutils import nodes
|
||||
import sphinx.writers.latex as latex
|
||||
import sphinx.writers.html as html
|
||||
|
||||
def replace_latex_question_mark(t):
|
||||
return t.replace(r"\PYGZsh{}\textless{}?\textgreater{}", u"\\large{【你的程序】}")
|
||||
|
||||
def replace_html_question_mark(t):
|
||||
return t.replace("#<?>", u'<span style="font-size:16px;font-weight:bold;">【你的程序】</span>')
|
||||
|
||||
def setup(app):
|
||||
print "code question loaded"
|
||||
old_depart_literal_block = latex.LaTeXTranslator.depart_literal_block
|
||||
def depart_literal_block(self, node):
|
||||
old_depart_literal_block(self, node)
|
||||
self.body[-1] = replace_latex_question_mark(self.body[-1])
|
||||
latex.LaTeXTranslator.depart_literal_block = depart_literal_block
|
||||
latex.LaTeXTranslator.depart_doctest_block = depart_literal_block
|
||||
|
||||
old_visit_literal_block = html.HTMLTranslator.visit_literal_block
|
||||
def visit_literal_block(self, node):
|
||||
try:
|
||||
old_visit_literal_block(self, node)
|
||||
finally:
|
||||
self.body[-1] = replace_html_question_mark(self.body[-1])
|
||||
|
||||
html.HTMLTranslator.visit_literal_block = visit_literal_block
|
||||
html.HTMLTranslator.visit_doctest_block = visit_literal_block
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from docutils import nodes
|
||||
import sphinx.writers.html as html
|
||||
import pdb
|
||||
|
||||
def setup(app):
|
||||
old_visit_reference = html.HTMLTranslator.visit_reference
|
||||
def visit_reference(self, node):
|
||||
if node.get('refid','').startswith("fig-"):
|
||||
text = node.children[0].children[0].astext()
|
||||
node.children[0].children[0] = nodes.Text(u"【图:%s】" % text)
|
||||
old_visit_reference(self, node)
|
||||
html.HTMLTranslator.visit_reference = visit_reference
|
|
@ -0,0 +1,88 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os.path as path
|
||||
import os
|
||||
from docutils import nodes
|
||||
from glob import glob
|
||||
import imghdr
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from docutils.utils import relative_path
|
||||
from sphinx.builders.latex import LaTeXBuilder
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
def process_images(self, docname, doctree):
|
||||
"""
|
||||
Process and rewrite image URIs.
|
||||
"""
|
||||
docdir = path.dirname(self.doc2path(docname, base=None))
|
||||
for node in doctree.traverse(nodes.image):
|
||||
# Map the mimetype to the corresponding image. The writer may
|
||||
# choose the best image from these candidates. The special key * is
|
||||
# set if there is only single candidate to be used by a writer.
|
||||
# The special key ? is set for nonlocal URIs.
|
||||
node['candidates'] = candidates = {}
|
||||
imguri = node['uri']
|
||||
if imguri.find('://') != -1:
|
||||
self.warn(docname, 'nonlocal image URI found: %s' % imguri,
|
||||
node.line)
|
||||
candidates['?'] = imguri
|
||||
continue
|
||||
# imgpath is the image path *from srcdir*
|
||||
if imguri.startswith('/') or imguri.startswith(os.sep):
|
||||
# absolute path (= relative to srcdir)
|
||||
imgpath = path.normpath(imguri[1:])
|
||||
else:
|
||||
imgpath = path.normpath(path.join(docdir, imguri))
|
||||
# set imgpath as default URI
|
||||
node['uri'] = imgpath
|
||||
if imgpath.endswith(os.extsep + '*'):
|
||||
for filename in glob(path.join(self.srcdir, imgpath)):
|
||||
new_imgpath = relative_path(self.srcdir, filename)
|
||||
if filename.lower().endswith('.pdf'):
|
||||
candidates['application/pdf'] = new_imgpath
|
||||
elif filename.lower().endswith('.svg'):
|
||||
candidates['image/svg+xml'] = new_imgpath
|
||||
elif ".latex." in filename.lower():
|
||||
candidates['latex'] = new_imgpath
|
||||
elif ".html." in filename.lower():
|
||||
candidates['html'] = new_imgpath
|
||||
else:
|
||||
try:
|
||||
f = open(filename, 'rb')
|
||||
try:
|
||||
imgtype = imghdr.what(f)
|
||||
finally:
|
||||
f.close()
|
||||
except (OSError, IOError), err:
|
||||
self.warn(docname, 'image file %s not '
|
||||
'readable: %s' % (filename, err),
|
||||
node.line)
|
||||
if imgtype:
|
||||
candidates['image/' + imgtype] = new_imgpath
|
||||
else:
|
||||
candidates['*'] = imgpath
|
||||
# map image paths to unique image names (so that they can be put
|
||||
# into a single directory)
|
||||
for imgpath in candidates.itervalues():
|
||||
self.dependencies.setdefault(docname, set()).add(imgpath)
|
||||
if not os.access(path.join(self.srcdir, imgpath), os.R_OK):
|
||||
self.warn(docname, 'image file not readable: %s' % imgpath,
|
||||
node.line)
|
||||
continue
|
||||
self.images.add_file(docname, imgpath)
|
||||
|
||||
from sphinx.util import url_re, get_matching_docs, docname_join, \
|
||||
FilenameUniqDict
|
||||
|
||||
def add_file(self, docname, newfile):
|
||||
if newfile in self:
|
||||
self[newfile][0].add(docname)
|
||||
return self[newfile][1]
|
||||
uniquename = path.basename(newfile)
|
||||
self[newfile] = (set([docname]), uniquename)
|
||||
self._existing.add(uniquename)
|
||||
return uniquename
|
||||
|
||||
def setup(app):
|
||||
FilenameUniqDict.add_file = add_file
|
||||
BuildEnvironment.process_images = process_images
|
||||
LaTeXBuilder.supported_image_types.insert(0, "latex")
|
||||
StandaloneHTMLBuilder.supported_image_types.insert(0, "html")
|
|
@ -0,0 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from docutils import nodes
|
||||
import sphinx.writers.latex as latex
|
||||
|
||||
def setup(app):
|
||||
latex.LaTeXTranslator.default_elements["babel"] = '\\usepackage[english]{babel}'
|
||||
#latex.LaTeXTranslator.default_elements["inputenc"] = ''
|
||||
|
|
@ -0,0 +1,931 @@
|
|||
%%
|
||||
%% This is file `xeCJK.sty',
|
||||
%% generated with the docstrip utility.
|
||||
%%
|
||||
%% The original source files were:
|
||||
%%
|
||||
%% xeCJK.dtx (with options: `xeCJK')
|
||||
%%
|
||||
%% Version 2.2.15 (17-June-2009)
|
||||
%%
|
||||
%% Copyright (C) Wenchang Sun <sunwch@hotmail.com>
|
||||
%%
|
||||
%% This file may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
\def\fileversion{2.2.15}
|
||||
\def\filedate{2009/06/17}
|
||||
\ProvidesPackage{xeCJK}[\filedate\space\fileversion]
|
||||
\RequirePackage{ifxetex}
|
||||
\RequireXeTeX
|
||||
\expandafter\def\csname ver@CJK.sty\endcsname{2020/01/01}
|
||||
\RequirePackage{fontspec}
|
||||
|
||||
\newif\ifxeCJK@SlantFont@
|
||||
\xeCJK@SlantFont@false
|
||||
|
||||
\newif\ifxeCJK@BoldFont@
|
||||
\xeCJK@BoldFont@false
|
||||
|
||||
\newif\ifxeCJK@num
|
||||
\xeCJK@numfalse
|
||||
|
||||
\newif\ifxeCJK@indisplay
|
||||
\xeCJK@indisplayfalse
|
||||
|
||||
\newif\ifxeCJK@addspaces
|
||||
\xeCJK@addspacesfalse
|
||||
|
||||
\newif\ifxeCJK@checksingle
|
||||
\xeCJK@checksinglefalse
|
||||
|
||||
\DeclareOption{boldfont}{\xeCJK@BoldFont@true}
|
||||
\DeclareOption{BoldFont}{\ExecuteOptions{boldfont}}
|
||||
\DeclareOption{slantfont}{\xeCJK@SlantFont@true}
|
||||
\DeclareOption{SlantFont}{\ExecuteOptions{slantfont}}
|
||||
\DeclareOption{CJKnumber}{\xeCJK@numtrue}
|
||||
\DeclareOption{CJKnormalspaces}{\xeCJK@addspacesfalse}
|
||||
\DeclareOption{CJKaddspaces}{\xeCJK@addspacestrue}
|
||||
\DeclareOption{CJKtextspaces}{}
|
||||
\DeclareOption{CJKmathspaces}{}
|
||||
\DeclareOption{CJKsetspaces}{}
|
||||
\DeclareOption{CJKnospaces}{}
|
||||
\DeclareOption{CJKchecksingle}{\xeCJK@checksingletrue}
|
||||
\ExecuteOptions{CJKaddspaces}\relax
|
||||
\ProcessOptions\relax
|
||||
\endlinechar \m@ne
|
||||
\XeTeXinterchartokenstate=1\relax
|
||||
|
||||
\def\xeCJKsetcharclass#1#2#3{
|
||||
\@tempcnta=#1
|
||||
\loop
|
||||
\XeTeXcharclass \@tempcnta #3\relax
|
||||
\advance\@tempcnta 1\relax
|
||||
\ifnum\the\@tempcnta<#2 \repeat
|
||||
\xeCJK@setpunctcharclass}
|
||||
|
||||
\def\xeCJK@prePunct#1#2{\xeCJK@setPunct{2}{#1}{#2}}
|
||||
\def\xeCJK@postPunct#1#2{\xeCJK@setPunct{3}{#1}{#2}}
|
||||
|
||||
\def\xeCJK@setPunct#1#2#3{
|
||||
\def\xeCJK@class{#1}
|
||||
\@tempcnta "#2\relax
|
||||
\multiply\@tempcnta 256\relax
|
||||
\xeCJK@setPunct@#3,,}
|
||||
|
||||
\def\xeCJK@setPunct@#1,{
|
||||
\edef\xeCJK@temp{#1}%
|
||||
\ifx\xeCJK@temp\@empty
|
||||
\else
|
||||
\@tempcntb "#1\relax
|
||||
\advance\@tempcntb\@tempcnta\relax
|
||||
\XeTeXcharclass \@tempcntb=\xeCJK@class\relax
|
||||
\def\xeCJK@temp{\xeCJK@setPunct@}
|
||||
\fi
|
||||
\xeCJK@temp}
|
||||
|
||||
\def\xeCJK@setpunctcharclass{
|
||||
\xeCJK@prePunct{20}{18,1C}
|
||||
\xeCJK@postPunct{20}{19,1D,14,26}
|
||||
\xeCJK@postPunct{25}{00}
|
||||
\xeCJK@prePunct{30}{08,0A,0C,0E,10,12,14,16,18,1A,1D,1F,36}
|
||||
|
||||
\xeCJK@postPunct{30}{01,02,05,06,09,0B,0D,0F,11,15,17,19,1B,1E,
|
||||
41,43,45,47,49,63,83,85,87,8E,
|
||||
9B,9C,9D,9E,A1,A3,A5,A7,A9,C3,E3,E5,E7,EE,F5,F6,FB,FC,FD,FE}
|
||||
\xeCJK@prePunct {FE}{59,5B,5D,5F,60,69,6B}
|
||||
\xeCJK@postPunct{FE}{50,51,52,54,55,56,57,5A,5C,5E,6A}
|
||||
\xeCJK@prePunct {FF}{03,04,08,20,3B,5B,E0,E1,E5,E6}
|
||||
\xeCJK@postPunct{FF}{01,05,09,0C,0E,1A,1B,1F,3D,5D,
|
||||
61,63,64,65,67,68,69,6A,6B,6C,6D,6E,6F,70,9E,9F}
|
||||
|
||||
\xeCJK@setPunct{4}{0}{28,2D,5B,60,7B}
|
||||
\xeCJK@setPunct{5}{0}{21,22,25,27,29,2C,2E,3A,3B,3F,5D,7D}}
|
||||
|
||||
\xeCJKsetcharclass{"2000}{"FFFF}{1}
|
||||
|
||||
\XeTeXinterchartoks 0 255 {\xeCJK@@cclv}
|
||||
\XeTeXinterchartoks 0 1 {\xeCJK@@i\xeCJK@char}
|
||||
\XeTeXinterchartoks 4 1 {\xeCJK@char}
|
||||
\XeTeXinterchartoks 5 1 {\xeCJK@v@i\xeCJK@char}
|
||||
\XeTeXinterchartoks 255 1 {\xeCJK@checksingle}
|
||||
|
||||
\XeTeXinterchartoks 0 2 {\xeCJK@prepunctchar}
|
||||
\XeTeXinterchartoks 4 2 {\xeCJK@prepunctchar}
|
||||
\XeTeXinterchartoks 5 2 {\xeCJK@prepunctchar}
|
||||
\XeTeXinterchartoks 255 2 {\xeCJK@prepunctchar}
|
||||
|
||||
\XeTeXinterchartoks 0 3 {\xeCJK@postpunctchar}
|
||||
\XeTeXinterchartoks 4 3 {\xeCJK@postpunctchar}
|
||||
\XeTeXinterchartoks 5 3 {\xeCJK@postpunctchar}
|
||||
\XeTeXinterchartoks 255 3 {\xeCJK@postpunctchar}
|
||||
|
||||
\XeTeXinterchartoks 255 0 {\xeCJK@cclv@}
|
||||
\XeTeXinterchartoks 255 4 {\xeCJK@cclv@iv}
|
||||
|
||||
\def\CJKglue{\hskip \z@ \@plus .08\baselineskip}
|
||||
\def\CJK@nobreakglue{\nobreak\CJKglue\nobreak}
|
||||
|
||||
\edef\xeCJK@CJKkern{\kern -1sp\kern 1sp}
|
||||
\edef\xeCJK@prepunctkern{\kern -2sp\kern 2sp}
|
||||
\edef\xeCJK@postpunctkern{\kern -3sp\kern 3sp}
|
||||
\edef\xeCJK@zerokern{\kern -4sp\kern 4sp}
|
||||
|
||||
\newif\if@xeCJK@inmath
|
||||
\@xeCJK@inmathfalse
|
||||
|
||||
\newif\if@xeCJK
|
||||
\def\xeCJK@ignorespaces{
|
||||
\futurelet\xeCJK@nexttoken\xeCJK@checknext}
|
||||
|
||||
\def\xeCJK@n@checknext{
|
||||
\ifx\xeCJK@nexttoken\@sptoken
|
||||
\expandafter\xeCJK@@checknext
|
||||
\fi}
|
||||
|
||||
{
|
||||
\def\:{\xeCJK@@checknext}
|
||||
\global\expandafter\def\: {\futurelet\@let@token\xeCJK@@@checknext}
|
||||
}
|
||||
|
||||
\def\CJK@stop{\CJK@stop}
|
||||
|
||||
\def\xeCJK@@@checknext{
|
||||
\ifcat L\noexpand\@let@token
|
||||
\else
|
||||
\let\xeCJK@nexttoken\relax
|
||||
\CJKecglue
|
||||
\fi}
|
||||
|
||||
\long\def\xeCJK@gobble#1\CJK@stop{}
|
||||
|
||||
|
||||
\def\xeCJK@notchecksingle{
|
||||
\xeCJK@cclv@i
|
||||
\xeCJK@char}
|
||||
|
||||
\def\xeCJK@z@checksingle#1{
|
||||
\def\xeCJK@setcurrentchar@i{
|
||||
\xeCJK@cclv@i
|
||||
\xeCJK@char{#1}}
|
||||
\def\xeCJK@setcurrentnobreakchar@i{
|
||||
\xeCJK@char{#1}}
|
||||
\futurelet\@let@token\xeCJK@@checksingle}
|
||||
|
||||
\def\xeCJK@@checksingle{
|
||||
\expandafter\futurelet
|
||||
\expandafter\xeCJK@tempb
|
||||
\expandafter\xeCJK@gobble\meaning\@let@token\CJK@stop
|
||||
\if t\xeCJK@tempb
|
||||
\expandafter\xeCJK@@@checksingle
|
||||
\else
|
||||
\expandafter\xeCJK@setcurrentchar@i
|
||||
\fi}
|
||||
|
||||
\def\xeCJK@@@checksingle#1{
|
||||
\def\xeCJK@setcurrentchar@ii{
|
||||
\xeCJK@setcurrentchar@i #1}
|
||||
\def\xeCJK@setcurrentnobreakchar@ii{
|
||||
\xeCJK@setcurrentnobreakchar@i #1}
|
||||
\futurelet\@let@token\xeCJK@@@@checksingle}
|
||||
|
||||
\def\xeCJK@@@@checksingle{
|
||||
\ifx\@let@token\@sptoken
|
||||
\expandafter\xeCJK@checkpar
|
||||
\else
|
||||
\expandafter\xeCJK@setcurrentchar@ii
|
||||
\fi}
|
||||
|
||||
\def\xeCJK@checkpar{
|
||||
\@ifnextchar\par{\xeCJK@setcurrentnobreakchar@ii}{\xeCJK@setcurrentchar@ii}}
|
||||
|
||||
\def\xeCJK@doaftermath{
|
||||
\futurelet\xeCJK@nexttoken\xeCJK@aftermath}
|
||||
|
||||
\def\xeCJK@z@cclv{\futurelet\xeCJK@nexttoken\xeCJK@zz@cclv}
|
||||
|
||||
\def\xeCJK@zz@cclv{
|
||||
\ifx\xeCJK@nexttoken\@sptoken
|
||||
\expandafter\xeCJK@zzz@cclv
|
||||
\else
|
||||
{\xeCJK@zerokern}
|
||||
\fi}
|
||||
|
||||
{
|
||||
\def\:{\xeCJK@zzz@cclv}
|
||||
\global\expandafter\def\: {\futurelet\@let@token\xeCJK@zzzz@cclv}
|
||||
}
|
||||
|
||||
\def\xeCJK@zzzz@cclv{
|
||||
\ifcat L\noexpand\@let@token
|
||||
\expandafter\xeCJK@zzzzz@cclv
|
||||
\else
|
||||
\xeCJK@space
|
||||
\fi}
|
||||
|
||||
\def\xeCJK@zzzzz@cclv#1{
|
||||
\ifnum`#1>"FF\relax
|
||||
\CJKecglue
|
||||
\else
|
||||
\xeCJK@space
|
||||
\fi
|
||||
#1}
|
||||
|
||||
\def\xeCJK@space{ }
|
||||
|
||||
\def\xeCJK@z@checknext{
|
||||
\ifx\xeCJK@nexttoken\@sptoken
|
||||
\expandafter\xeCJK@@checknext
|
||||
\else
|
||||
\ifx $\xeCJK@nexttoken
|
||||
\CJKecglue
|
||||
\fi
|
||||
\fi}
|
||||
|
||||
\def\CJKaddspaces{
|
||||
\let\xeCJK@@cclv\xeCJK@z@cclv
|
||||
\let\CJKecglue\CJK@ecglue
|
||||
\let\xeCJK@@i\CJKecglue
|
||||
\let\xeCJK@v@i\CJKecglue
|
||||
|
||||
\def\xeCJK@cclv@{
|
||||
\ifnum\lastkern=1\relax
|
||||
\CJKecglue
|
||||
\fi}
|
||||
\let\xeCJK@cclv@iv\xeCJK@cclv@
|
||||
|
||||
\def\xeCJK@cclv@i{{
|
||||
\ifcase\lastkern
|
||||
\hskip 0pt
|
||||
\or %1
|
||||
\CJKglue
|
||||
\or %2
|
||||
\xeCJK@ULspecials
|
||||
\or %3
|
||||
\xeCJK@ULspecials
|
||||
\or %4
|
||||
\CJKecglue
|
||||
\fi}}
|
||||
|
||||
\everymath{\ifxeCJK@indisplay\else\aftergroup\xeCJK@doaftermath\fi}
|
||||
\everydisplay{\xeCJK@indisplaytrue}
|
||||
\let\xeCJK@checknext\xeCJK@z@checknext
|
||||
\let\xeCJK@aftermath\xeCJK@zz@cclv}
|
||||
|
||||
\def\CJKnormalspaces{
|
||||
\let\xeCJK@@cclv\relax
|
||||
\let\xeCJK@@i\relax
|
||||
\let\xeCJK@v@i\relax
|
||||
\let\xeCJK@checknext\xeCJK@n@checknext
|
||||
\def\CJKecglue{ }
|
||||
|
||||
\def\xeCJK@cclv@{
|
||||
\ifodd\lastkern
|
||||
\xeCJK@@glue
|
||||
\fi}
|
||||
\let\xeCJK@cclv@iv\xeCJK@cclv@
|
||||
|
||||
\def\xeCJK@cclv@i{{
|
||||
\ifcase\lastkern
|
||||
\hskip 0pt
|
||||
\or %1
|
||||
\CJKglue
|
||||
\or %2
|
||||
\xeCJK@ULspecials
|
||||
\or %3
|
||||
\xeCJK@ULspecials
|
||||
\fi}}
|
||||
|
||||
\def\xeCJK@@glue{
|
||||
\ifx\xeCJK@nexttoken\@sptoken
|
||||
{ }
|
||||
\fi
|
||||
\let\xeCJK@nexttoken\relax}
|
||||
\everymath{}
|
||||
\everydisplay{}}
|
||||
|
||||
\def\xeCJK@setspacemode{
|
||||
\ifxeCJK@addspaces
|
||||
\CJKaddspaces
|
||||
\else
|
||||
\CJKnormalspaces
|
||||
\fi
|
||||
\ifxeCJK@checksingle
|
||||
\let\xeCJK@checksingle\xeCJK@z@checksingle
|
||||
\else
|
||||
\let\xeCJK@checksingle\xeCJK@notchecksingle
|
||||
\fi}
|
||||
|
||||
\def\CJK@ecglue{ }
|
||||
|
||||
\def\xeCJKsetecglue#1{
|
||||
\ifxeCJK@addspaces
|
||||
\def\CJK@ecglue{#1}
|
||||
\let\CJKecglue\CJK@ecglue
|
||||
\let\xeCJK@@i\CJKecglue
|
||||
\let\xeCJK@v@i\CJKecglue
|
||||
\fi}
|
||||
\let\CJKsetecglue\xeCJKsetecglue
|
||||
\CJKaddspaces
|
||||
|
||||
\AtBeginDocument{
|
||||
\xeCJK@setspacemode
|
||||
\ifcsname UL@hook\endcsname
|
||||
\addto@hook\UL@hook{
|
||||
\let\xeCJK@unskip\xeCJK@UL@unskip
|
||||
\let\xeCJK@ULspecials\xeCJK@UL@punctgroup}
|
||||
\fi}
|
||||
\DeclareRobustCommand{\xeCJK@char}[1]{
|
||||
{\XeTeXinterchartokenstate=0
|
||||
\CJKsymbol{#1}
|
||||
\xeCJK@CJKkern}
|
||||
\xeCJK@ignorespaces}
|
||||
\DeclareRobustCommand{\xeCJK@prepunctchar}[1]{
|
||||
{\xeCJK@punctrule{#1}{l}
|
||||
\@xeCJKfalse
|
||||
\ifnum\lastkern>1\relax
|
||||
\ifnum\lastkern<4\relax
|
||||
\unkern
|
||||
\unkern
|
||||
\ifnum\xeCJK@punctstyle>0\relax
|
||||
\@xeCJKtrue
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
\if@xeCJK
|
||||
\xeCJK@unskip
|
||||
\xeCJK@setkern{\@xeCJK@lastpunct}{#1}
|
||||
\kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\@xeCJK@lastpunct#1\endcsname
|
||||
\xeCJKpunctnobreak
|
||||
\else
|
||||
\xeCJK@ULspecials
|
||||
\hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @lglue@#1\endcsname
|
||||
plus 0.1em minus 0.1 em
|
||||
\fi
|
||||
|
||||
\global\edef\@xeCJK@lastpunct{#1}
|
||||
\vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
|
||||
@lrule@#1\endcsname depth \z@ height \z@
|
||||
|
||||
\XeTeXinterchartokenstate=0
|
||||
\CJKpunctsymbol{#1}
|
||||
|
||||
\nobreak
|
||||
\gdef\xeCJK@lastcharclass{2}
|
||||
\xeCJK@prepunctkern}
|
||||
\ignorespaces}
|
||||
\DeclareRobustCommand{\xeCJK@postpunctchar}[1]{
|
||||
{\xeCJK@punctrule{#1}{r}
|
||||
\@xeCJKfalse
|
||||
\ifnum\lastkern>1\relax
|
||||
\ifnum\lastkern<4\relax
|
||||
\unkern
|
||||
\unkern
|
||||
\@xeCJKtrue
|
||||
\fi
|
||||
\fi
|
||||
\if@xeCJK
|
||||
\xeCJK@unskip
|
||||
\xeCJK@setkern{\@xeCJK@lastpunct}{#1}
|
||||
\kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
|
||||
@kern\@xeCJK@lastpunct#1\endcsname
|
||||
\nobreak
|
||||
\else
|
||||
\xeCJK@ULspecials
|
||||
\ifcsname xeCJK@specialpunct#1\endcsname
|
||||
\CJKglue % breakable
|
||||
\else
|
||||
\nobreak
|
||||
\fi
|
||||
\fi
|
||||
\global\edef\@xeCJK@lastpunct{#1}
|
||||
|
||||
\XeTeXinterchartokenstate=0
|
||||
\CJKpunctsymbol{#1}
|
||||
|
||||
\vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
|
||||
@rrule@#1\endcsname depth \z@ height \z@
|
||||
|
||||
\hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rglue@#1\endcsname
|
||||
plus 0.1em minus 0.1 em
|
||||
|
||||
\gdef\xeCJK@lastcharclass{3}
|
||||
\xeCJK@postpunctkern}
|
||||
\xeCJK@ignorespaces}
|
||||
|
||||
\let\xeCJK@unskip\unskip
|
||||
\def\xeCJK@UL@unskip{
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rglue@\@xeCJK@lastpunct\endcsname
|
||||
\hskip -\csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
|
||||
@rglue@\@xeCJK@lastpunct\endcsname\relax
|
||||
\fi}
|
||||
\def\xeCJKallowbreakbetweenpuncts{
|
||||
\def\xeCJKpunctnobreak{
|
||||
\ifnum\xeCJK@lastcharclass=3
|
||||
\hskip 0pt
|
||||
\fi}}
|
||||
|
||||
\def\xeCJKnobreakbetweenpuncts{
|
||||
\let\xeCJKpunctnobreak\nobreak}
|
||||
\xeCJKnobreakbetweenpuncts
|
||||
\newcount\xeCJK@cnta
|
||||
\newcount\xeCJK@cntb
|
||||
\newcount\xeCJK@cntc
|
||||
\newcount\xeCJK@cntd
|
||||
\newcount\xeCJK@cnte
|
||||
\newif\ifxeCJK@dokerning
|
||||
|
||||
\def\xeCJK@punctrule#1#2{
|
||||
\ifcsname xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname
|
||||
\global\edef\xeCJK@bboxname{
|
||||
\csname xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname}
|
||||
\else
|
||||
\xeCJK@getbboxname
|
||||
\ifcsname xeCJK@\xeCJK@bboxname @spaces\endcsname
|
||||
\PackageInfo{xeCJK}{Loading punct spaces for '\xeCJK@bboxname'}
|
||||
\expandafter\expandafter\expandafter
|
||||
\xeCJK@setpunctspaces\csname xeCJK@\xeCJK@bboxname @spaces\endcsname
|
||||
\else
|
||||
\PackageInfo{xeCJK}{Punct spaces for '\xeCJK@bboxname' not found. Loading 'def' instead.}
|
||||
\gdef\xeCJK@bboxname{def}
|
||||
\fi
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname{\xeCJK@bboxname}
|
||||
\fi
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2rule@#1\endcsname
|
||||
\else
|
||||
\xeCJK@dokerningtrue
|
||||
\ifnum\xeCJK@punctstyle=\xeCJK@ps@plain\relax
|
||||
\xeCJK@dokerningfalse
|
||||
\else
|
||||
\ifcsname xeCJK@specialpunct#1\endcsname
|
||||
\xeCJK@dokerningfalse
|
||||
\else
|
||||
\ifcsname xeCJK@\xeCJK@bboxname @#2space@#1\endcsname
|
||||
\else
|
||||
\typeout{.....xeCJK@\xeCJK@bboxname @#2space@.......false................}
|
||||
\xeCJK@dokerningfalse
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
\ifxeCJK@dokerning
|
||||
\xeCJK@cnta=\csname xeCJK@\xeCJK@bboxname @#2space@#1\endcsname\relax
|
||||
\xeCJK@cntc=\xeCJK@cnta
|
||||
\ifcase\xeCJK@punctstyle
|
||||
% hangmobanjiao
|
||||
\or % quanjiao
|
||||
\or % banjiao
|
||||
\advance\xeCJK@cntc -5\relax
|
||||
\or % kaiming
|
||||
\ifcsname xeCJK@kaiming#1\endcsname
|
||||
\else
|
||||
\advance\xeCJK@cntc -5\relax
|
||||
\fi
|
||||
\or %CCT
|
||||
\advance\xeCJK@cntc -2\relax
|
||||
\fi
|
||||
\xeCJK@cntd=\xeCJK@cntc
|
||||
\ifnum\xeCJK@cntc<0\relax
|
||||
\xeCJK@cntc=0\relax
|
||||
\fi
|
||||
\else
|
||||
\xeCJK@cnta=0\relax
|
||||
\xeCJK@cntc=0\relax
|
||||
\xeCJK@cntd=0\relax
|
||||
\fi
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2rule@#1\endcsname{
|
||||
-0.\the\xeCJK@cnta em}
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2glue@#1\endcsname{
|
||||
0.\the\xeCJK@cntc em}
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2oglue@#1\endcsname{
|
||||
\the\xeCJK@cntd}
|
||||
\fi}
|
||||
|
||||
\def\xeCJK@getbboxname{
|
||||
{\csname xeCJK@font@\xeCJK@family\endcsname
|
||||
\get@external@font
|
||||
\global\let\xeCJK@tempx\external@font}
|
||||
\expandafter\xeCJK@@getbboxname\xeCJK@tempx\relax
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname{\xeCJK@bboxname}}
|
||||
|
||||
\def\xeCJK@@getbboxname"#1/#2"#3\relax{
|
||||
\edef\xeCJK@temp{\zap@space #1 \@empty}
|
||||
\edef\xeCJK@temp{\lowercase{\gdef\noexpand\xeCJK@bboxname{\xeCJK@temp}}}
|
||||
\xeCJK@temp}
|
||||
|
||||
\expandafter\def\csname xeCJK@kaiming。\endcsname{}
|
||||
\expandafter\def\csname xeCJK@kaiming?\endcsname{}
|
||||
\expandafter\def\csname xeCJK@kaiming!\endcsname{}
|
||||
\expandafter\def\csname xeCJK@specialpunct—\endcsname{}% U+2014
|
||||
\expandafter\def\csname xeCJK@specialpunct─\endcsname{}% U+2500
|
||||
\expandafter\def\csname xeCJK@specialpunct…\endcsname{}
|
||||
\def\xeCJK@setkern#1#2{
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname
|
||||
\else
|
||||
\xeCJK@cnta=0\relax
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#1\endcsname
|
||||
\advance\xeCJK@cnta\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#1\endcsname
|
||||
\fi
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @loglue@#2\endcsname
|
||||
\advance\xeCJK@cnta\csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
|
||||
@loglue@#2\endcsname
|
||||
\fi
|
||||
\relax
|
||||
\ifcase\xeCJK@punctstyle
|
||||
% hangmobanjiao
|
||||
\or % quanjiao
|
||||
\advance\xeCJK@cnta -5\relax
|
||||
\or % banjiao
|
||||
\or % kaiming
|
||||
\ifcsname xeCJK@kaiming#1\endcsname
|
||||
\ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#2\endcsname
|
||||
\advance\xeCJK@cnta -5\relax
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
\ifnum\xeCJK@cnta<0\relax
|
||||
\xeCJK@cnta=0\relax
|
||||
\fi
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname{
|
||||
0.\the\xeCJK@cnta em}
|
||||
\fi}
|
||||
|
||||
\def\xeCJKsetkern#1#2#3{
|
||||
\xeCJK@getbboxname
|
||||
\global\expandafter\edef\csname
|
||||
xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname{#3}}
|
||||
|
||||
\def\punctstyle#1{
|
||||
\ifcsname xeCJK@ps@#1\endcsname
|
||||
\edef\xeCJK@punctstyle{\csname xeCJK@ps@#1\endcsname}
|
||||
\ifnum\xeCJK@punctstyle=\xeCJK@ps@plain\relax
|
||||
\xeCJKallowbreakbetweenpuncts
|
||||
\fi
|
||||
\else
|
||||
\typeout{Warning: Punctstyle #1\space is not defined.}
|
||||
\fi}
|
||||
|
||||
\def\xeCJK@ps@hangmobanjiao{0}
|
||||
\def\xeCJK@ps@marginkerning{0}
|
||||
\def\xeCJK@ps@quanjiao{1}
|
||||
\def\xeCJK@ps@fullwidth{1}
|
||||
\def\xeCJK@ps@banjiao{2}
|
||||
\def\xeCJK@ps@halfwidth{2}
|
||||
\def\xeCJK@ps@kaiming{3}
|
||||
\def\xeCJK@ps@mixedwidth{3}
|
||||
\def\xeCJK@ps@CCT{4}
|
||||
\def\xeCJK@ps@plain{5}
|
||||
\punctstyle{quanjiao}
|
||||
|
||||
\let\@afterindentfalse\relax
|
||||
|
||||
\def\xeCJKplainchr{\punctstyle{plain}}
|
||||
|
||||
\def\xeCJK@setpunctspaces#1,#2,#3,{
|
||||
\edef\xeCJK@tempa{#1}
|
||||
\ifx\xeCJK@tempa\@empty
|
||||
\else
|
||||
\def\xeCJK@tempa{\xeCJK@setpunctspaces}
|
||||
\ifcsname xeCJK@specialpunct#1\endcsname
|
||||
\ifx#1…
|
||||
\else
|
||||
\xeCJK@cnta=#2\relax
|
||||
\advance\xeCJK@cnta #3\relax
|
||||
\ifcsname xeCJKpunct.spa.version\endcsname
|
||||
\multiply\xeCJK@cnta 10\relax
|
||||
\fi
|
||||
\advance\xeCJK@cnta 2\relax
|
||||
\ifnum\xeCJK@cnta>9
|
||||
\edef\xeCJK@temp{-0.\the\xeCJK@cnta em}
|
||||
\else
|
||||
\ifnum\xeCJK@cnta>1
|
||||
\edef\xeCJK@temp{-0.0\the\xeCJK@cnta em}
|
||||
\else
|
||||
\edef\xeCJK@temp{-0.01 em}
|
||||
\fi
|
||||
\fi
|
||||
\xeCJK@cnta=0
|
||||
\loop
|
||||
\global\expandafter\edef\csname xeCJK\the\xeCJK@cnta\xeCJK@bboxname
|
||||
@kern#1#1\endcsname{\xeCJK@temp}
|
||||
\advance \xeCJK@cnta 1\relax
|
||||
\ifnum\xeCJK@cnta<6\repeat
|
||||
\fi
|
||||
\fi
|
||||
\xeCJK@setspace{#2}
|
||||
\global\expandafter\edef\csname xeCJK@\xeCJK@bboxname @lspace@#1\endcsname{\the\xeCJK@cnta}
|
||||
\xeCJK@setspace{#3}
|
||||
\global\expandafter\edef\csname xeCJK@\xeCJK@bboxname @rspace@#1\endcsname{\the\xeCJK@cnta}
|
||||
\fi
|
||||
\xeCJK@tempa}
|
||||
|
||||
\def\xeCJK@setspace#1{
|
||||
\xeCJK@cnta=#1\relax
|
||||
\ifcsname xeCJKpunct.spa.version\endcsname
|
||||
\multiply\xeCJK@cnta 10\relax
|
||||
\fi
|
||||
\advance\xeCJK@cnta -\xeCJK@sidespace\relax
|
||||
\divide\xeCJK@cnta 10\relax
|
||||
\ifnum\xeCJK@cnta<0\relax
|
||||
\xeCJK@cnta=0\relax
|
||||
\fi}
|
||||
\def\xeCJK@sidespace{10}
|
||||
|
||||
\def\xeCJK@def@spaces{‘,6,0,“,4,0,「,4,1,『,4,1,〔,4,1,(,5,0,[,5,1,{,4,1,
|
||||
〈,4,1,《,4,0,〖,4,0,【,4,0,─,0,0,—,0,0,…,0,0,、,0,6,。,0,6,,,0,7,
|
||||
.,1,7,:,1,6,;,1,6,!,2,6,?,1,3,%,1,1,〕,0,4,),1,5,],1,5,},1,4,
|
||||
〉,1,4,》,0,4,〗,0,4,】,0,4,’,0,6,”,0,4,」,1,4,』,1,4,,,,}
|
||||
|
||||
{
|
||||
\def\xeCJK@bboxname{def}
|
||||
\expandafter\def\csname xeCJKpunct.spa.version\endcsname{}
|
||||
\expandafter\xeCJK@setpunctspaces\xeCJK@def@spaces
|
||||
}
|
||||
|
||||
\InputIfFileExists{xeCJKpunct.spa}{}{}
|
||||
|
||||
\def\CJKsymbol#1{{\xeCJK@setfont #1}}
|
||||
\def\CJKpunctsymbol#1{{\xeCJK@setfont #1}}
|
||||
\def\xeCJK@setfont{
|
||||
\ifcsname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname
|
||||
\csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname
|
||||
\else
|
||||
\csname xeCJK@font@\xeCJK@family\endcsname
|
||||
\get@external@font
|
||||
\expandafter\global\expandafter\font
|
||||
\csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname=\external@font
|
||||
\fi}
|
||||
|
||||
\def\setCJKmainfont{
|
||||
\xeCJK@newfontfamily{rm}}
|
||||
|
||||
\let\setCJKromanfont\setCJKmainfont
|
||||
|
||||
\def\setCJKsansfont{
|
||||
\xeCJK@newfontfamily{sf}}
|
||||
|
||||
\def\setCJKmonofont{
|
||||
\xeCJK@newfontfamily{tt}}
|
||||
|
||||
\def\setCJKfamilyfont#1{
|
||||
\xeCJK@newfontfamily{#1}}
|
||||
|
||||
\DeclareRobustCommand\rmfamily
|
||||
{\not@math@alphabet\rmfamily\mathrm
|
||||
\fontfamily\rmdefault\CJKfamily{rm}\selectfont}
|
||||
|
||||
\DeclareRobustCommand\sffamily
|
||||
{\not@math@alphabet\sffamily\mathsf
|
||||
\fontfamily\sfdefault\CJKfamily{sf}\selectfont}
|
||||
|
||||
\DeclareRobustCommand\ttfamily
|
||||
{\not@math@alphabet\ttfamily\mathtt
|
||||
\fontfamily\ttdefault\CJKfamily{tt}\selectfont}
|
||||
|
||||
\newcommand*\xeCJK@newfontfamily[1]{
|
||||
\@ifnextchar[
|
||||
{\xeCJK@newfontfamily@{#1}}
|
||||
{\xeCJK@newfontfamily@{#1}[]}}
|
||||
|
||||
\def\xeCJK@newfontfamily@#1[#2]#3{
|
||||
%
|
||||
% Get user defined options
|
||||
\def\xeCJK@temp{#2}
|
||||
\expandafter
|
||||
\xeCJK@getBoldFont\xeCJK@temp BoldFont={}{}\relax
|
||||
\expandafter
|
||||
\xeCJK@getBoldItalicFont\xeCJK@temp BoldItalicFont={}{}\relax
|
||||
\expandafter
|
||||
\xeCJK@getItalicFont\xeCJK@temp ItalicFont={}{}\relax
|
||||
|
||||
\expandafter
|
||||
\xeCJK@getBoldItalicFeatures\xeCJK@temp BoldItalicFeatures={}{}\relax
|
||||
\expandafter
|
||||
\xeCJK@getBoldFeatures\xeCJK@temp BoldFeatures={}{}\relax
|
||||
\expandafter
|
||||
\xeCJK@getItalicFeatures\xeCJK@temp ItalicFeatures={}{}\relax
|
||||
|
||||
\expandafter
|
||||
\xeCJK@getRawFeature\xeCJK@BoldFeatures RawFeature={}{}\relax
|
||||
\edef\xeCJK@Bold@RawFeature{\xeCJK@tempRawFeature}
|
||||
|
||||
\expandafter
|
||||
\xeCJK@getRawFeature\xeCJK@BoldItalicFeatures RawFeature={}{}\relax
|
||||
\edef\xeCJK@BoldItalic@RawFeature{\xeCJK@tempRawFeature}
|
||||
|
||||
\expandafter
|
||||
\xeCJK@getRawFeature\xeCJK@ItalicFeatures RawFeature={}{}\relax
|
||||
\edef\xeCJK@Italic@RawFeature{\xeCJK@tempRawFeature}
|
||||
|
||||
\edef\xeCJK@Features{}
|
||||
|
||||
\ifxeCJK@BoldFont@
|
||||
\ifx\xeCJK@BoldFont\@empty
|
||||
|
||||
\ifx\xeCJK@Bold@RawFeature\@empty
|
||||
\def\xeCJK@Bold@RawFeature{
|
||||
embolden=\xeCJK@emboldenfactor}
|
||||
\else
|
||||
\edef\xeCJK@Bold@RawFeature{
|
||||
embolden=\xeCJK@emboldenfactor,
|
||||
\xeCJK@Bold@RawFeature}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@BoldFeatures\@empty
|
||||
\edef\xeCJK@Features{
|
||||
BoldFeatures={
|
||||
RawFeature={\xeCJK@Bold@RawFeature}}}
|
||||
\else
|
||||
\edef\xeCJK@Features{
|
||||
BoldFeatures={
|
||||
\xeCJK@BoldFeatures,
|
||||
RawFeature={\xeCJK@Bold@RawFeature}}}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@BoldItalic@RawFeature\@empty
|
||||
\def\xeCJK@BoldItalic@RawFeature{
|
||||
embolden=\xeCJK@emboldenfactor}
|
||||
\else
|
||||
\edef\xeCJK@BoldItalic@RawFeature{
|
||||
embolden=\xeCJK@emboldenfactor,
|
||||
\xeCJK@BoldItalic@RawFeature}
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
|
||||
\ifxeCJK@SlantFont@
|
||||
\ifx\xeCJK@ItalicFont\@empty
|
||||
|
||||
\ifx\xeCJK@Italic@RawFeature\@empty
|
||||
\edef\xeCJK@Italic@RawFeature{
|
||||
slant=\xeCJK@slantfactor}
|
||||
\else
|
||||
\edef\xeCJK@Italic@RawFeature{
|
||||
slant=\xeCJK@slantfactor,
|
||||
\xeCJK@Italic@RawFeature}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@ItalicFeatures\@empty
|
||||
\edef\xeCJK@ItalicFeatures{
|
||||
RawFeature={\xeCJK@Italic@RawFeature}}
|
||||
\else
|
||||
\edef\xeCJK@ItalicFeatures{
|
||||
\xeCJK@ItalicFeatures,
|
||||
RawFeature={\xeCJK@Italic@RawFeature}}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@BoldItalic@RawFeature\@empty
|
||||
\edef\xeCJK@BoldItalic@RawFeature{
|
||||
slant=\xeCJK@slantfactor}
|
||||
\else
|
||||
\edef\xeCJK@BoldItalic@RawFeature{
|
||||
slant=\xeCJK@slantfactor,
|
||||
\xeCJK@BoldItalic@RawFeature}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@BoldItalicFeatures\@empty
|
||||
\edef\xeCJK@BoldItalicFeatures{
|
||||
RawFeature={\xeCJK@BoldItalic@RawFeature}}
|
||||
\else
|
||||
\edef\xeCJK@BoldItalicFeatures{
|
||||
\xeCJK@BoldItalicFeatures,
|
||||
RawFeature={\xeCJK@BoldItalic@RawFeature}}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@Features\@empty
|
||||
\edef\xeCJK@Features{
|
||||
ItalicFeatures={\xeCJK@ItalicFeatures},
|
||||
BoldItalicFeatures={\xeCJK@BoldItalicFeatures}}
|
||||
\else
|
||||
\edef\xeCJK@Features{
|
||||
\xeCJK@Features,
|
||||
ItalicFeatures={\xeCJK@ItalicFeatures},
|
||||
BoldItalicFeatures={\xeCJK@BoldItalicFeatures}}
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
|
||||
\edef\xeCJK@temp{#2}
|
||||
\ifx\xeCJK@temp\@empty
|
||||
\else
|
||||
\edef\xeCJK@temp{,#2}
|
||||
\fi
|
||||
|
||||
\ifx\xeCJK@Features\@empty
|
||||
\else
|
||||
\edef\xeCJK@Features{,\xeCJK@Features}
|
||||
\fi
|
||||
|
||||
\edef\xeCJK@Features{
|
||||
[BoldFont={#3},
|
||||
ItalicFont={#3},
|
||||
BoldItalicFont={#3}% The first three parameters can be overridden by
|
||||
% user defined parameters in #2
|
||||
\xeCJK@temp\xeCJK@Features]}
|
||||
|
||||
\expandafter
|
||||
\newfontfamily@i\csname xeCJK@font@#1\expandafter\endcsname
|
||||
\xeCJK@Features
|
||||
{#3}}
|
||||
|
||||
\def\xeCJK@setmacro@getkey#1{
|
||||
\expandafter\def\csname xeCJK@get#1\endcsname ##1#1=##2##3\relax{
|
||||
\expandafter\edef\csname xeCJK@#1\endcsname{##2}
|
||||
\edef\xeCJK@temp{##1##3}}}
|
||||
|
||||
\xeCJK@setmacro@getkey{BoldFont}
|
||||
\xeCJK@setmacro@getkey{ItalicFont}
|
||||
\xeCJK@setmacro@getkey{BoldItalicFont}
|
||||
\xeCJK@setmacro@getkey{ItalicFeatures}
|
||||
\xeCJK@setmacro@getkey{BoldFeatures}
|
||||
\xeCJK@setmacro@getkey{BoldItalicFeatures}
|
||||
|
||||
\def\xeCJK@getRawFeature#1RawFeature=#2#3\relax{
|
||||
\edef\xeCJK@tempRawFeature{#2}}
|
||||
|
||||
\define@key[zf]{preparse}{ItalicFeatures}{
|
||||
\edef\zf@it@feat{,#1}
|
||||
\edef\zf@family@long{\zf@family@long itfeat:#1}}
|
||||
|
||||
|
||||
\def\xeCJK@font@rm{}
|
||||
|
||||
\DeclareRobustCommand\CJKfamily[1]{
|
||||
\ifcsname xeCJK@font@#1\endcsname
|
||||
\def\xeCJK@family{#1}
|
||||
\else
|
||||
\ifcsname xeCJK@#1@warned\endcsname
|
||||
\else
|
||||
\PackageWarning{xeCJK}{
|
||||
Unknown CJK family `#1' is ignored.^^J
|
||||
Use \string\setCJKfamilyfont \space to define a CJK family.}
|
||||
\expandafter\gdef\csname xeCJK@#1@warned\endcsname{}
|
||||
\fi
|
||||
\fi}
|
||||
\CJKfamily{rm}
|
||||
|
||||
\def\xeCJKsetslantfactor#1{\edef\xeCJK@slantfactor{#1}}
|
||||
\def\xeCJKsetemboldenfactor#1{\edef\xeCJK@emboldenfactor{#1}}
|
||||
|
||||
\xeCJKsetslantfactor{0.17}
|
||||
\xeCJKsetemboldenfactor{4}
|
||||
\@ifundefined{UL@hskip}{\let\UL@hskip\relax}{}
|
||||
|
||||
\let\xeCJK@ULspecials\relax
|
||||
|
||||
\def\xeCJK@UL@punctgroup{
|
||||
\ifx\hskip\UL@hskip
|
||||
\egroup
|
||||
\UL@stop
|
||||
\UL@start
|
||||
\bgroup
|
||||
\fi}
|
||||
|
||||
\ifxeCJK@num
|
||||
\edef\CJK@UnicodeEnc{UTF8}
|
||||
\def\CJKaddEncHook#1#2{\expandafter\def\csname xeCJK@enc@#1\endcsname{#2}}
|
||||
\def\Unicode#1#2{\@tempcnta #1\relax
|
||||
\multiply\@tempcnta 256\relax
|
||||
\advance\@tempcnta #2\relax
|
||||
\char\@tempcnta}
|
||||
\RequirePackage{CJKnumb}
|
||||
\csname xeCJK@enc@UTF8\endcsname
|
||||
\def\CJK@tenthousand{万}
|
||||
\fi
|
||||
|
||||
\def\CJK@ifundefined#1{
|
||||
\ifx #1\@undefined
|
||||
\expandafter\@firstoftwo
|
||||
\else
|
||||
\expandafter\@secondoftwo
|
||||
\fi
|
||||
}
|
||||
|
||||
\newcommand{\xeCJKcaption}[2][]{
|
||||
\edef\xeCJK@temp{#1}
|
||||
\ifx\xeCJK@temp\@empty
|
||||
\else
|
||||
\XeTeXdefaultencoding "#1"
|
||||
\fi
|
||||
\makeatletter
|
||||
\input{#2.cpx}
|
||||
\makeatother
|
||||
\XeTeXdefaultencoding "UTF-8"}
|
||||
|
||||
\def\CJKlanguage#1{}
|
||||
\endlinechar `\^^M
|
||||
\catcode "FEFF=9\relax
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `xeCJK.sty'.
|
|
@ -0,0 +1,137 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import os.path as path
|
||||
import codecs
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils import nodes
|
||||
import sphinx.directives.code as code
|
||||
import re
|
||||
from sphinx.util import parselinenos
|
||||
|
||||
from number_label import CircleNumbers
|
||||
|
||||
def replace_number_label(text):
|
||||
def f(mo):
|
||||
return u"#"+CircleNumbers[int(mo.group(1))-1]
|
||||
return re.sub(r"#{(\d+)}", f, text)
|
||||
|
||||
def run(self):
|
||||
document = self.state.document
|
||||
filename = self.arguments[0]
|
||||
#print filename
|
||||
if not document.settings.file_insertion_enabled:
|
||||
return [document.reporter.warning('File insertion disabled',
|
||||
line=self.lineno)]
|
||||
env = document.settings.env
|
||||
if filename.startswith('/') or filename.startswith(os.sep):
|
||||
rel_fn = filename[1:]
|
||||
else:
|
||||
docdir = path.dirname(env.doc2path(env.docname, base=None))
|
||||
rel_fn = path.normpath(path.join(docdir, filename))
|
||||
fn = path.join(env.srcdir, rel_fn)
|
||||
|
||||
if 'pyobject' in self.options and 'lines' in self.options:
|
||||
return [document.reporter.warning(
|
||||
'Cannot use both "pyobject" and "lines" options',
|
||||
line=self.lineno)]
|
||||
|
||||
encoding = self.options.get('encoding', env.config.source_encoding)
|
||||
try:
|
||||
f = codecs.open(fn, 'rU', encoding)
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
# 去掉编码指示
|
||||
if fn.endswith(".py") and lines[0].startswith("#") and "coding" in lines[0]:
|
||||
lines = lines[1:]
|
||||
# 去掉文档说明
|
||||
if fn.endswith(".py"):
|
||||
if lines[0].startswith('"""'):
|
||||
for lineno, line in enumerate(lines[1:]):
|
||||
if line.strip().endswith('"""'):
|
||||
lines = lines[lineno+2:]
|
||||
break
|
||||
# 去掉每行末尾空格
|
||||
for i in xrange(len(lines)):
|
||||
lines[i] = lines[i].rstrip() + "\n"
|
||||
|
||||
except (IOError, OSError):
|
||||
return [document.reporter.warning(
|
||||
'Include file %r not found or reading it failed' % filename,
|
||||
line=self.lineno)]
|
||||
except UnicodeError:
|
||||
return [document.reporter.warning(
|
||||
'Encoding %r used for reading included file %r seems to '
|
||||
'be wrong, try giving an :encoding: option' %
|
||||
(encoding, filename))]
|
||||
|
||||
objectname = self.options.get('pyobject')
|
||||
if objectname is not None:
|
||||
from sphinx.pycode import ModuleAnalyzer
|
||||
analyzer = ModuleAnalyzer.for_file(fn, '')
|
||||
tags = analyzer.find_tags()
|
||||
if objectname not in tags:
|
||||
return [document.reporter.warning(
|
||||
'Object named %r not found in include file %r' %
|
||||
(objectname, filename), line=self.lineno)]
|
||||
else:
|
||||
lines = lines[tags[objectname][1]-1 : tags[objectname][2]-1]
|
||||
|
||||
linespec = self.options.get('lines')
|
||||
if linespec is not None:
|
||||
try:
|
||||
linelist = parselinenos(linespec, len(lines))
|
||||
except ValueError, err:
|
||||
return [document.reporter.warning(str(err), line=self.lineno)]
|
||||
lines = [lines[i] for i in linelist]
|
||||
|
||||
startafter = self.options.get('start-after')
|
||||
endbefore = self.options.get('end-before')
|
||||
if startafter is not None or endbefore is not None:
|
||||
use = not startafter
|
||||
res = []
|
||||
for line in lines:
|
||||
if not use and startafter in line:
|
||||
use = True
|
||||
elif use and endbefore in line:
|
||||
use = False
|
||||
break
|
||||
elif use:
|
||||
res.append(line)
|
||||
lines = res
|
||||
|
||||
section = self.options.get("section")
|
||||
if section is not None:
|
||||
section = "###%s###" % section
|
||||
print section
|
||||
use = False
|
||||
res = []
|
||||
for line in lines:
|
||||
if not use and section in line:
|
||||
use = True
|
||||
continue
|
||||
elif use and section in line:
|
||||
use = False
|
||||
break
|
||||
if use:
|
||||
res.append(line)
|
||||
lines = res
|
||||
indent = len(lines[0]) - len(lines[0].lstrip())
|
||||
for i,line in enumerate(lines):
|
||||
lines[i] = line[indent:]
|
||||
|
||||
text = replace_number_label(''.join(lines))
|
||||
text = re.sub(r"(?s)#<\?(.*?)>.+?#<\?/>", lambda mo:u"#<?>%s" % mo.group(1), text)
|
||||
#text = (u"#程序文件:%s\n" % filename) + text
|
||||
retnode = nodes.literal_block(text, text, source=fn)
|
||||
retnode.line = 1
|
||||
if self.options.get('language', ''):
|
||||
retnode['language'] = self.options['language']
|
||||
if 'linenos' in self.options:
|
||||
retnode['linenos'] = True
|
||||
document.settings.env.note_dependency(rel_fn)
|
||||
#print "LiteralInclude hacked"
|
||||
return [retnode]
|
||||
|
||||
def setup(app):
|
||||
code.LiteralInclude.option_spec["section"] = directives.unchanged_required
|
||||
code.LiteralInclude.run = run
|
|
@ -0,0 +1,4 @@
|
|||
from sphinx import highlighting
|
||||
def highlight_block(self, source, lang, linenos=False, warn=None):
|
||||
return self.unhighlighted(source)
|
||||
highlighting.PygmentsBridge.highlight_block = highlight_block
|
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from docutils import nodes
|
||||
import sphinx.writers.latex as latex
|
||||
import sphinx.writers.html as html
|
||||
|
||||
CircleNumbers = u"❶❷❸❹❺❻❼❽❾❿"
|
||||
|
||||
def replace_latex_code_labels(t):
|
||||
for i, n in enumerate(CircleNumbers):
|
||||
target = r"{\normalsize\ding{%s}}" % (202+i)
|
||||
target2 = r"[@normalsize@ding[%s]]" % (202+i)
|
||||
t = t.replace(r"\PYG{c}{\PYGZsh{}%s}" % n, target)
|
||||
t = t.replace(r"\PYG{c}{\#%s}" % n, target)
|
||||
t = t.replace(r"@#%s" % n, target2)
|
||||
return t
|
||||
|
||||
def replace_latex_text_labels(t):
|
||||
for i, n in enumerate(CircleNumbers):
|
||||
t = t.replace(n, r"{\Large\ding{%s}}\hspace{1mm}" % (202+i))
|
||||
return t
|
||||
|
||||
def replace_html_code_labels(t):
|
||||
for i, n in enumerate(CircleNumbers):
|
||||
target = '<span class="prebc">#</span><span class="codenumber">%s</span>' % n
|
||||
t = t.replace("#%s" % n, target).replace("#{%d}" % (i+1), target).replace("#{{%d}}" % (i+1), "#{%d}" % (i+1))
|
||||
return t
|
||||
|
||||
def setup(app):
|
||||
print "number_label loaded"
|
||||
old_depart_literal_block = latex.LaTeXTranslator.depart_literal_block
|
||||
def depart_literal_block(self, node):
|
||||
old_depart_literal_block(self, node)
|
||||
self.body[-1] = replace_latex_code_labels(self.body[-1])
|
||||
latex.LaTeXTranslator.depart_literal_block = depart_literal_block
|
||||
latex.LaTeXTranslator.depart_doctest_block = depart_literal_block
|
||||
|
||||
old_visit_Text = latex.LaTeXTranslator.visit_Text
|
||||
def visit_Text(self, node):
|
||||
old_visit_Text(self, node)
|
||||
self.body[-1] = replace_latex_text_labels(self.body[-1])
|
||||
latex.LaTeXTranslator.visit_Text = visit_Text
|
||||
|
||||
old_visit_literal_block = html.HTMLTranslator.visit_literal_block
|
||||
def visit_literal_block(self, node):
|
||||
try:
|
||||
old_visit_literal_block(self, node)
|
||||
finally:
|
||||
self.body[-1] = replace_html_code_labels(self.body[-1])
|
||||
|
||||
html.HTMLTranslator.visit_literal_block = visit_literal_block
|
||||
html.HTMLTranslator.visit_doctest_block = visit_literal_block
|
|
@ -0,0 +1,66 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from docutils import nodes
|
||||
import sphinx.writers.latex as latex
|
||||
from sphinx.util.nodes import clean_astext
|
||||
import pdb
|
||||
def doctree_resolved(app, doctree, docname):
|
||||
"""将带sec-开头的target标签名添加到标签的父节点之上
|
||||
这样就可以在section节点之下定义章节的标签。便于用
|
||||
leo的auto-rst功能编辑rst文档。
|
||||
|
||||
例如:
|
||||
|
||||
章节名称
|
||||
--------
|
||||
|
||||
.. _sec-test:
|
||||
|
||||
章节内容
|
||||
"""
|
||||
for node in doctree.traverse(nodes.target):
|
||||
if node.get("refid", "").startswith("sec-"):
|
||||
section = node.parent
|
||||
section["ids"].append(node["refid"])
|
||||
node["refid"] = "-" + node["refid"]
|
||||
|
||||
def doctree_read(app, doctree):
|
||||
"""
|
||||
为了sec-开头标签能正常工作需要将其添加进:
|
||||
env.domains["std"].data["labels"]
|
||||
sec-test: 文章名, 标签名, 章节名,
|
||||
"""
|
||||
labels = app.env.domains["std"].data["labels"]
|
||||
for name, _ in doctree.nametypes.iteritems():
|
||||
if not name.startswith("sec-"): continue
|
||||
labelid = doctree.nameids[name]
|
||||
node = doctree.ids[labelid].parent
|
||||
if node.tagname == 'section':
|
||||
sectname = clean_astext(node[0])
|
||||
labels[name] = app.env.docname, labelid, sectname
|
||||
|
||||
def setup(app):
|
||||
print "number_ref loaded"
|
||||
old_visit_reference = latex.LaTeXTranslator.visit_reference
|
||||
def visit_reference(self, node):
|
||||
uri = node.get('refuri', '')
|
||||
hashindex = uri.find('#')
|
||||
if hashindex == -1:
|
||||
id = uri[1:] + '::doc'
|
||||
else:
|
||||
id = uri[1:].replace('#', ':')
|
||||
if uri.startswith("%") and "#fig-" in uri:
|
||||
self.body.append(self.hyperlink(id))
|
||||
self.body.append(u"图\\ref*{%s}" % id)
|
||||
self.context.append("}}")
|
||||
raise nodes.SkipChildren
|
||||
elif uri.startswith("%") and "#sec-" in uri:
|
||||
self.body.append(self.hyperlink(id))
|
||||
self.body.append(u"第\\ref*{%s}节" % id)
|
||||
self.context.append("}}")
|
||||
raise nodes.SkipChildren
|
||||
else:
|
||||
return old_visit_reference(self, node)
|
||||
latex.LaTeXTranslator.visit_reference = visit_reference
|
||||
|
||||
app.connect("doctree-read", doctree_read)
|
||||
app.connect("doctree-resolved", doctree_resolved)
|
|
@ -0,0 +1,144 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
class SEG(object):
|
||||
def __init__(self):
|
||||
_localDir=os.path.dirname(__file__)
|
||||
_curpath=os.path.normpath(os.path.join(os.getcwd(),_localDir))
|
||||
curpath=_curpath
|
||||
self.d = {}
|
||||
print >> sys.stderr,"loading dict..."
|
||||
self.set([x.rstrip() for x in file(os.path.join(curpath,"main.dic")) ])
|
||||
self.specialwords= set([x.rstrip().decode('utf-8') for x in file(os.path.join(curpath,"suffix.dic"))])
|
||||
print >> sys.stderr,'dict ok.'
|
||||
#set dictionary(a list)
|
||||
def set(self,keywords):
|
||||
p = self.d
|
||||
q = {}
|
||||
k = ''
|
||||
for word in keywords:
|
||||
word = (chr(11)+word).decode('utf-8')
|
||||
if len(word)>5:
|
||||
continue
|
||||
p = self.d
|
||||
ln = len(word)
|
||||
for i in xrange(ln-1,-1,-1):
|
||||
char = word[i].lower()
|
||||
if p=='':
|
||||
q[k] = {}
|
||||
p = q[k]
|
||||
if not (char in p):
|
||||
p[char] = ''
|
||||
q = p
|
||||
k = char
|
||||
p = p[char]
|
||||
|
||||
pass
|
||||
|
||||
def _binary_seg(self,s):
|
||||
ln = len(s)
|
||||
if ln==1:
|
||||
return [s]
|
||||
R = []
|
||||
for i in xrange(ln,1,-1):
|
||||
tmp = s[i-2:i]
|
||||
R.append(tmp)
|
||||
return R
|
||||
|
||||
def _pro_unreg(self,piece):
|
||||
#print piece
|
||||
R = []
|
||||
tmp = re.sub(u"。|,|,|!|…|!|《|》|<|>|\"|'|:|:|?|\?|、|\||“|”|‘|’|;|—|(|)|·|\(|\)| "," ",piece).split()
|
||||
ln1 = len(tmp)
|
||||
for i in xrange(len(tmp)-1,-1,-1):
|
||||
mc = re.split(r"([0-9A-Za-z\-\+#@_\.]+)",tmp[i])
|
||||
for j in xrange(len(mc)-1,-1,-1):
|
||||
r = mc[j]
|
||||
if re.search(r"([0-9A-Za-z\-\+#@_\.]+)",r)!=None:
|
||||
R.append(r)
|
||||
else:
|
||||
R.extend(self._binary_seg(r))
|
||||
return R
|
||||
|
||||
|
||||
def cut(self,text):
|
||||
"""
|
||||
"""
|
||||
text = text.decode('utf-8','ignore')
|
||||
p = self.d
|
||||
ln = len(text)
|
||||
i = ln
|
||||
j = 0
|
||||
z = ln
|
||||
q = 0
|
||||
recognised = []
|
||||
mem = None
|
||||
mem2 = None
|
||||
while i-j>0:
|
||||
t = text[i-j-1].lower()
|
||||
#print i,j,t,mem
|
||||
if not (t in p):
|
||||
if (mem!=None) or (mem2!=None):
|
||||
if mem!=None:
|
||||
i,j,z = mem
|
||||
mem = None
|
||||
elif mem2!=None:
|
||||
delta = mem2[0]-i
|
||||
if delta>=1:
|
||||
if (delta<5) and (re.search(ur"[\w\u2E80-\u9FFF]",t)!=None):
|
||||
pre = text[i-j]
|
||||
#print pre
|
||||
if not (pre in self.specialwords):
|
||||
i,j,z,q = mem2
|
||||
del recognised[q:]
|
||||
mem2 = None
|
||||
|
||||
p = self.d
|
||||
if((i<ln) and (i<z)):
|
||||
unreg_tmp = self._pro_unreg(text[i:z])
|
||||
recognised.extend(unreg_tmp)
|
||||
recognised.append(text[i-j:i])
|
||||
#print text[i-j:i],mem2
|
||||
i = i-j
|
||||
z = i
|
||||
j = 0
|
||||
continue
|
||||
j = 0
|
||||
i -= 1
|
||||
p = self.d
|
||||
continue
|
||||
p = p[t]
|
||||
j+=1
|
||||
if chr(11) in p:
|
||||
if j<=2:
|
||||
mem = i,j,z
|
||||
#print text[i-1]
|
||||
if (z-i<2) and (text[i-1] in self.specialwords) and ((mem2==None) or ((mem2!=None and mem2[0]-i>1))):
|
||||
#print text[i-1]
|
||||
mem = None
|
||||
mem2 = i,j,z,len(recognised)
|
||||
p = self.d
|
||||
i -= 1
|
||||
j = 0
|
||||
continue
|
||||
#print mem
|
||||
p = self.d
|
||||
#print i,j,z,text[i:z]
|
||||
if((i<ln) and (i<z)):
|
||||
unreg_tmp = self._pro_unreg(text[i:z])
|
||||
recognised.extend(unreg_tmp)
|
||||
recognised.append(text[i-j:i])
|
||||
i = i-j
|
||||
z = i
|
||||
j = 0
|
||||
mem = None
|
||||
mem2 = None
|
||||
#print mem
|
||||
if mem!=None:
|
||||
i,j,z = mem
|
||||
recognised.extend(self._pro_unreg(text[i:z]))
|
||||
recognised.append(text[i-j:i])
|
||||
else:
|
||||
recognised.extend(self._pro_unreg(text[i-j:z]))
|
||||
return recognised
|
|
@ -0,0 +1,114 @@
|
|||
和
|
||||
是
|
||||
了
|
||||
中
|
||||
有
|
||||
都
|
||||
的
|
||||
来
|
||||
在
|
||||
次
|
||||
还
|
||||
但
|
||||
为
|
||||
里
|
||||
用
|
||||
外
|
||||
上
|
||||
下
|
||||
就
|
||||
以
|
||||
去
|
||||
即
|
||||
丁
|
||||
万
|
||||
乔
|
||||
余
|
||||
候
|
||||
傅
|
||||
冯
|
||||
刘
|
||||
单
|
||||
卢
|
||||
史
|
||||
叶
|
||||
吕
|
||||
吴
|
||||
唐
|
||||
夏
|
||||
姚
|
||||
姜
|
||||
孔
|
||||
孙
|
||||
孟
|
||||
宋
|
||||
尹
|
||||
崔
|
||||
常
|
||||
康
|
||||
廖
|
||||
张
|
||||
彭
|
||||
徐
|
||||
戴
|
||||
文
|
||||
方
|
||||
易
|
||||
曹
|
||||
曾
|
||||
朱
|
||||
李
|
||||
杜
|
||||
杨
|
||||
林
|
||||
梁
|
||||
武
|
||||
段
|
||||
毛
|
||||
江
|
||||
汤
|
||||
沈
|
||||
潘
|
||||
熊
|
||||
王
|
||||
田
|
||||
白
|
||||
石
|
||||
秦
|
||||
罗
|
||||
肖
|
||||
胡
|
||||
苏
|
||||
范
|
||||
董
|
||||
蒋
|
||||
薛
|
||||
袁
|
||||
谢
|
||||
谭
|
||||
贾
|
||||
赖
|
||||
赵
|
||||
邓
|
||||
邱
|
||||
邵
|
||||
邹
|
||||
郑
|
||||
郝
|
||||
郭
|
||||
金
|
||||
钟
|
||||
钱
|
||||
阎
|
||||
陆
|
||||
陈
|
||||
雷
|
||||
韩
|
||||
顾
|
||||
马
|
||||
高
|
||||
魏
|
||||
黄
|
||||
黎
|
||||
龙
|
||||
龚
|
|
@ -0,0 +1,197 @@
|
|||
{#
|
||||
basic/layout.html
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Master layout template for Sphinx themes.
|
||||
|
||||
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
#}
|
||||
|
||||
{% set script_files = script_files + ["_static/comment.js"] %}
|
||||
{% set css_files = css_files + ["_static/comment.css"] %}
|
||||
|
||||
{%- block doctype -%}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
{%- endblock %}
|
||||
{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %}
|
||||
{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
|
||||
{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
|
||||
(sidebars != []) %}
|
||||
{%- set url_root = pathto('', 1) %}
|
||||
{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
|
||||
|
||||
{%- macro relbar() %}
|
||||
<div class="related">
|
||||
<h3>{{ _('Navigation') }}</h3>
|
||||
<ul>
|
||||
{%- for rellink in rellinks %}
|
||||
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
|
||||
<a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}"
|
||||
{{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
|
||||
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
|
||||
{%- endfor %}
|
||||
{%- block rootrellink %}
|
||||
<li><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
|
||||
{%- endblock %}
|
||||
{%- for parent in parents %}
|
||||
<li><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
|
||||
{%- endfor %}
|
||||
{%- block relbaritems %} {% endblock %}
|
||||
</ul>
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro sidebar() %}
|
||||
{%- if render_sidebar %}
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
{%- block sidebarlogo %}
|
||||
<p class="logo"><a href="http://tengine.taobao.org/">
|
||||
<img class="logo" src="{{ pathto('_static/logo.png', 1) }}" alt="Logo"/>
|
||||
</a></p>
|
||||
{%- endblock %}
|
||||
{%- if sidebars != None %}
|
||||
{#- new style sidebar: explicitly include/exclude templates #}
|
||||
{%- for sidebartemplate in sidebars %}
|
||||
{%- include sidebartemplate %}
|
||||
{%- endfor %}
|
||||
{%- else %}
|
||||
{#- old style sidebars: using blocks -- should be deprecated #}
|
||||
{%- block sidebartoc %}
|
||||
{%- include "localtoc.html" %}
|
||||
{%- endblock %}
|
||||
{%- block sidebarrel %}
|
||||
{%- include "relations.html" %}
|
||||
{%- endblock %}
|
||||
{%- block sidebarsourcelink %}
|
||||
{%- include "sourcelink.html" %}
|
||||
{%- endblock %}
|
||||
{%- if customsidebar %}
|
||||
{%- include customsidebar %}
|
||||
{%- endif %}
|
||||
{%- block sidebarsearch %}
|
||||
{%- include "searchbox.html" %}
|
||||
{%- endblock %}
|
||||
{%- endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
|
||||
{{ metatags }}
|
||||
{%- if not embedded and docstitle %}
|
||||
{%- set titlesuffix = " — "|safe + docstitle|e %}
|
||||
{%- else %}
|
||||
{%- set titlesuffix = "" %}
|
||||
{%- endif %}
|
||||
{%- block htmltitle %}
|
||||
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
|
||||
{%- endblock %}
|
||||
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
||||
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
|
||||
{%- for cssfile in css_files %}
|
||||
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
|
||||
{%- endfor %}
|
||||
{%- if not embedded %}
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '{{ url_root }}',
|
||||
VERSION: '{{ release|e }}',
|
||||
COLLAPSE_INDEX: false,
|
||||
FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}',
|
||||
HAS_SOURCE: {{ has_source|lower }}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/??ga.js,correctpng.js?v=1"></script>
|
||||
{%- for scriptfile in script_files %}
|
||||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
||||
{%- endfor %}
|
||||
{%- if use_opensearch %}
|
||||
<link rel="search" type="application/opensearchdescription+xml"
|
||||
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
|
||||
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
|
||||
{%- endif %}
|
||||
{%- if favicon %}
|
||||
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- block linktags %}
|
||||
{%- if hasdoc('about') %}
|
||||
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('genindex') %}
|
||||
<link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('search') %}
|
||||
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('copyright') %}
|
||||
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
|
||||
{%- endif %}
|
||||
<link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}" />
|
||||
{%- if parents %}
|
||||
<link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}" />
|
||||
{%- endif %}
|
||||
{%- if next %}
|
||||
<link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}" />
|
||||
{%- endif %}
|
||||
{%- if prev %}
|
||||
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- block extrahead %} {% endblock %}
|
||||
</head>
|
||||
<body lang="zh-Hans">
|
||||
{%- block header %}{% endblock %}
|
||||
|
||||
{%- block relbar1 %}{{ relbar() }}{% endblock %}
|
||||
|
||||
{%- block content %}
|
||||
{%- block sidebar1 %} {# possible location for sidebar #} {% endblock %}
|
||||
|
||||
<div class="document">
|
||||
{%- block document %}
|
||||
<div class="documentwrapper">
|
||||
{%- if render_sidebar %}
|
||||
<div class="bodywrapper">
|
||||
{%- endif %}
|
||||
<div class="body">
|
||||
{% block body %} {% endblock %}
|
||||
</div>
|
||||
{%- if render_sidebar %}
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
{%- endblock %}
|
||||
|
||||
{%- block sidebar2 %}{{ sidebar() }}{% endblock %}
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
{%- endblock %}
|
||||
|
||||
{%- block relbar2 %}{{ relbar() }}{% endblock %}
|
||||
|
||||
{%- block footer %}
|
||||
<div class="footer">
|
||||
{%- if show_copyright %}
|
||||
{%- if hasdoc('copyright') %}
|
||||
{% trans path=pathto('copyright'), copyright=copyright|e %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
|
||||
{%- else %}
|
||||
{% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- if last_updated %}
|
||||
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{%- if show_sphinx %}
|
||||
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
</div>
|
||||
{%- endblock %}
|
||||
</body>
|
||||
</html>
|
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
* sphinxdoc.css_t
|
||||
* ~~~~~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- sphinxdoc theme. Originally created by
|
||||
* Armin Ronacher for Werkzeug.
|
||||
*
|
||||
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: segoe UI,sans-serif;
|
||||
font-size: 16px;
|
||||
letter-spacing: -0.01em;
|
||||
line-height: 150%;
|
||||
text-align: center;
|
||||
background-color: #E7E7E2;
|
||||
color: black;
|
||||
padding: 0;
|
||||
border: 1px solid #aaa;
|
||||
margin: 0px 140px 0px 140px;
|
||||
min-width: 900px;
|
||||
}
|
||||
|
||||
div.document {
|
||||
background-color: white;
|
||||
text-align: left;
|
||||
background-image: url(contents.png);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 240px;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.body {
|
||||
margin: 0;
|
||||
padding: 0.5em 20px 20px 20px;
|
||||
}
|
||||
|
||||
div.related {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.related ul {
|
||||
background-image: url(navigation.png);
|
||||
height: 2em;
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
div.related ul li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 2em;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.related ul li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
div.related ul li a {
|
||||
margin: 0;
|
||||
padding: 0 5px 0 5px;
|
||||
line-height: 1.75em;
|
||||
color: #224466;
|
||||
}
|
||||
|
||||
div.related ul li a:hover {
|
||||
color: #3CA8E7;
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
margin: 0;
|
||||
padding: 0.5em 15px 15px 15px;
|
||||
margin-left: -100%;
|
||||
width: 210px;
|
||||
float: left;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3, div.sphinxsidebar h4 {
|
||||
margin: 1em 0 0.5em 0;
|
||||
font-size: 1em;
|
||||
padding: 0.1em 0 0.1em 0.5em;
|
||||
color: white;
|
||||
border: 1px solid #86989B;
|
||||
background-color: #666;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
padding-left: 1.5em;
|
||||
margin-top: 7px;
|
||||
padding: 0;
|
||||
line-height: 130%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
div.footer {
|
||||
background-color: #444444;
|
||||
color: #ffffff;
|
||||
padding: 3px 8px 3px 0;
|
||||
clear: both;
|
||||
font-size: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: #ffffff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
p {
|
||||
margin: 0.8em 0 0.5em 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #224466;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #2491CF;
|
||||
}
|
||||
|
||||
div.body a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0.7em 0 0.3em 0;
|
||||
font-size: 1.8em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 1.3em 0 0.2em 0;
|
||||
font-size: 1.35em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 1em 0 -0.3em 0;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
div.body h1 a, div.body h2 a, div.body h3 a, div.body h4 a, div.body h5 a, div.body h6 a {
|
||||
color: black!important;
|
||||
}
|
||||
|
||||
h1 a.anchor, h2 a.anchor, h3 a.anchor, h4 a.anchor, h5 a.anchor, h6 a.anchor {
|
||||
display: none;
|
||||
margin: 0 0 0 0.3em;
|
||||
padding: 0 0.2em 0 0.2em;
|
||||
color: #aaa!important;
|
||||
}
|
||||
|
||||
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor,
|
||||
h5:hover a.anchor, h6:hover a.anchor {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover,
|
||||
h5 a.anchor:hover, h6 a.anchor:hover {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
a.headerlink {
|
||||
color: #c60f0f!important;
|
||||
font-size: 1em;
|
||||
margin-left: 6px;
|
||||
padding: 0 4px 0 4px;
|
||||
text-decoration: none!important;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
background-color: #ccc;
|
||||
color: white!important;
|
||||
}
|
||||
|
||||
cite, code, tt {
|
||||
font-family: 'Consolas', 'Deja Vu Sans Mono',
|
||||
'Bitstream Vera Sans Mono', monospace;
|
||||
font-size: 0.95em;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
tt {
|
||||
background-color: #f2f2f2;
|
||||
border-bottom: 1px solid #ddd;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
tt.descname, tt.descclassname, tt.xref {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 1px solid #abc;
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
a tt {
|
||||
border: 0;
|
||||
color: #CA7900;
|
||||
}
|
||||
|
||||
a tt:hover {
|
||||
color: #2491CF;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: 'Consolas', 'Deja Vu Sans Mono',
|
||||
'Bitstream Vera Sans Mono', monospace;
|
||||
font-size: 0.95em;
|
||||
letter-spacing: 0.015em;
|
||||
line-height: 120%;
|
||||
padding: 0.5em;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
pre a {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
|
||||
div.quotebar {
|
||||
background-color: #f8f8f8;
|
||||
max-width: 250px;
|
||||
float: right;
|
||||
padding: 2px 7px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin: 0 -0.5em 0 -0.5em;
|
||||
}
|
||||
|
||||
table td, table th {
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
}
|
||||
|
||||
div.admonition, div.warning {
|
||||
font-size: 0.9em;
|
||||
margin: 1em 0 1em 0;
|
||||
border: 1px solid #86989B;
|
||||
background-color: #f7f7f7;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.admonition p, div.warning p {
|
||||
margin: 0.5em 1em 0.5em 1em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.admonition pre, div.warning pre {
|
||||
margin: 0.4em 1em 0.4em 1em;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
margin: 0;
|
||||
padding: 0.1em 0 0.1em 0.5em;
|
||||
color: white;
|
||||
border-bottom: 1px solid #86989B;
|
||||
font-weight: bold;
|
||||
background-color: #AFC1C4;
|
||||
}
|
||||
|
||||
div.warning {
|
||||
border: 1px solid #940000;
|
||||
}
|
||||
|
||||
div.warning p.admonition-title {
|
||||
background-color: #CF0000;
|
||||
border-bottom-color: #940000;
|
||||
}
|
||||
|
||||
div.admonition ul, div.admonition ol,
|
||||
div.warning ul, div.warning ol {
|
||||
margin: 0.1em 0.5em 0.5em 3em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.versioninfo {
|
||||
margin: 1em 0 0 0;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #DDEAF0;
|
||||
padding: 8px;
|
||||
line-height: 1.3em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
|
||||
'Verdana', sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
background-color: #f4debf;
|
||||
border-top: 1px solid #ac9;
|
||||
border-bottom: 1px solid #ac9;
|
||||
}
|
||||
|
||||
i, cite, em, var, address {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.prebc {
|
||||
color: #F8F8F8;
|
||||
}
|
||||
|
||||
.codenumber {
|
||||
color:black;
|
||||
font-family:segoe UI,sans-serif;
|
||||
}
|
||||
|
||||
div.imagebox {
|
||||
min-height:25px;
|
||||
border:1px solid #777777;
|
||||
background-color:#eeeeee;
|
||||
background-repeat: no-repeat;
|
||||
padding-left:40px;
|
||||
padding-top:4px;
|
||||
padding-bottom:4px;
|
||||
padding-right:4px;
|
||||
background-position: 5px center;
|
||||
margin:5px;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
div.imagebox p{
|
||||
margin:2px;
|
||||
line-height:100%;
|
||||
}
|
||||
|
||||
form.search input[name=q]{
|
||||
width:200px;
|
||||
}
|
||||
|
||||
form.search input[type=submit]{
|
||||
width:50px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #666;
|
||||
font-family:segoe UI,sans-serif;
|
||||
}
|
||||
|
||||
div.figure p.caption{
|
||||
padding-left:20px;
|
||||
background-image: url(picture.png);
|
||||
background-repeat:no-repeat;
|
||||
background-position:center left;
|
||||
}
|
||||
|
||||
table.docutils{
|
||||
border 1px solid #666;
|
||||
}
|
||||
|
||||
table.docutils caption{
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
p.logo{text-align:center;}
|
|
@ -0,0 +1,62 @@
|
|||
jQuery.cookie = function(name, value, options) {
|
||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||
options = options || {};
|
||||
if (value === null) {
|
||||
value = '';
|
||||
options.expires = -1;
|
||||
}
|
||||
var expires = '';
|
||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||
var date;
|
||||
if (typeof options.expires == 'number') {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||
} else {
|
||||
date = options.expires;
|
||||
}
|
||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||
}
|
||||
var path = options.path ? '; path=' + options.path : '';
|
||||
var domain = options.domain ? '; domain=' + options.domain : '';
|
||||
var secure = options.secure ? '; secure' : '';
|
||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||
} else { // only name given, get cookie
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
};
|
||||
|
||||
hide_sidebar = function(){
|
||||
$("div.bodywrapper").css("margin-left", "0px");
|
||||
$("div.sphinxsidebar").hide();
|
||||
$.cookie("hide_sidebar","1");
|
||||
};
|
||||
|
||||
show_sidebar = function(){
|
||||
$("div.bodywrapper").css("margin-left", "240px");
|
||||
$("div.sphinxsidebar").show();
|
||||
$.cookie("hide_sidebar", "", {expires:-1});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('<li class="right"><a href="#" id="toggle_sidebar">切换侧栏(ALT+X)</a> | </li>')
|
||||
.insertBefore($(".related:first li:eq(3)"));
|
||||
|
||||
$("a#toggle_sidebar").toggle(hide_sidebar, show_sidebar);
|
||||
|
||||
$(window).keydown(function(event){
|
||||
if(event.altKey && event.keyCode == 88) $("a#toggle_sidebar").click();
|
||||
});
|
||||
|
||||
});
|
After Width: | Height: | Size: 744 B |
|
@ -0,0 +1,20 @@
|
|||
div.comment {
|
||||
position:absolute;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
}
|
||||
div.comment a.email_link {
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
text-decoration:none;
|
||||
background: transparent url(./comment_white_yellow.gif) no-repeat -16px 0;
|
||||
}
|
||||
|
||||
div.comment a.email_link:hover{
|
||||
background-position:0 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
110414 lizziesky:
|
||||
仅包含 生成 comments 小icon, 且点击icon 跳转到groups的逻辑,
|
||||
- 优化了DOM结构,
|
||||
- 去除了 window.resize 事件
|
||||
- 去除 仿google code 文档的侧栏切换
|
||||
*/
|
||||
DESELEMENT = "h1,h2,h3,h4,.highlight-python";//"h1,h2,h3,h4,ul,div.section p,div.highlight-python";
|
||||
|
||||
function clean_tag(st){
|
||||
return st.replace(/<[^>]+>?[^<]*>/g, '');
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("div.body > div.section").find(DESELEMENT).each(function() {
|
||||
if (!$(this).prev("div.comment").length) {
|
||||
var cmt = $('<div class="comment"><a class="email_link" title="点击提交Issue,反馈你的意见..."></a></div>');
|
||||
$(this).before(cmt);
|
||||
cmt.offset({
|
||||
left: $(this).parents('.section').offset().left - 20,
|
||||
top: $(this).offset().top
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("a.email_link").hover(function(){
|
||||
if ($(this).attr("href") == null||$(this).attr("href") == '') {
|
||||
var sub = $("div.documentwrapper div.body div.section:first h1").html();
|
||||
var body = $(this).parent("div.comment").next().html();
|
||||
// collection doc info from DOCUMENTATION_OPTIONS
|
||||
sub = clean_tag(sub);
|
||||
|
||||
body = clean_tag(body);
|
||||
if (body.length>100) {
|
||||
body = body.substring(0, 100)+"...";
|
||||
}
|
||||
//091117:Zoomq change comment aim
|
||||
//$(this).attr("href", "https://groups.google.com/group/obp-comment/post?hl=zh-CN&subject="+encodeURIComponent(sub)+"&body="+encodeURIComponent(body));
|
||||
//$(this).attr("href", "https://bitbucket.org/ZoomQuiet/obp.rwiwpyzh/issues/new");
|
||||
$(this).attr("href", "https://github.com/taobao/nginx-book/issues/new?title="+encodeURIComponent(sub)+"+"+encodeURIComponent(body)+"&body="+encodeURIComponent("current content:\n ...\nadvice:\n ...\nreason:\n ...\n"));
|
||||
$(this).attr("target", "_blank");
|
||||
}
|
||||
}, function(){
|
||||
});
|
||||
|
||||
});
|
||||
|
After Width: | Height: | Size: 441 B |
After Width: | Height: | Size: 1006 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 606 B |
|
@ -0,0 +1,62 @@
|
|||
.highlight .hll { background-color: #ffffcc }
|
||||
.highlight { background: #eeffcc; }
|
||||
.highlight .c { color: #408090; font-style: normal } /* Comment */
|
||||
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
||||
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
|
||||
.highlight .o { color: #666666 } /* Operator */
|
||||
.highlight .cm { color: #408090; font-style: normal } /* Comment.Multiline */
|
||||
.highlight .cp { color: #007020 } /* Comment.Preproc */
|
||||
.highlight .c1 { color: #408090; font-style: normal } /* Comment.Single */
|
||||
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
|
||||
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
||||
.highlight .ge { font-style: normal } /* Generic.Emph */
|
||||
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
||||
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
||||
.highlight .go { color: #303030 } /* Generic.Output */
|
||||
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||||
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||||
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
||||
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
|
||||
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
|
||||
.highlight .kt { color: #902000 } /* Keyword.Type */
|
||||
.highlight .m { color: #208050 } /* Literal.Number */
|
||||
.highlight .s { color: #4070a0 } /* Literal.String */
|
||||
.highlight .na { color: #4070a0 } /* Name.Attribute */
|
||||
.highlight .nb { color: #007020 } /* Name.Builtin */
|
||||
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
|
||||
.highlight .no { color: #60add5 } /* Name.Constant */
|
||||
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
|
||||
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
|
||||
.highlight .ne { color: #007020 } /* Name.Exception */
|
||||
.highlight .nf { color: #06287e } /* Name.Function */
|
||||
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
|
||||
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
|
||||
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
|
||||
.highlight .nv { color: #bb60d5 } /* Name.Variable */
|
||||
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
|
||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.highlight .mf { color: #208050 } /* Literal.Number.Float */
|
||||
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
|
||||
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
|
||||
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
|
||||
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
|
||||
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
|
||||
.highlight .sd { color: #4070a0; font-style: normal } /* Literal.String.Doc */
|
||||
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
|
||||
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
|
||||
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
|
||||
.highlight .si { color: #70a0d0; font-style: normal } /* Literal.String.Interpol */
|
||||
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
|
||||
.highlight .sr { color: #235388 } /* Literal.String.Regex */
|
||||
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
|
||||
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
|
||||
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
|
||||
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
|
||||
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
|
||||
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
|
||||
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
|
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,4 @@
|
|||
[theme]
|
||||
inherit = basic
|
||||
stylesheet = book.css
|
||||
pygments_style = friendly
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from sphinx.search import SearchLanguage
|
||||
from smallseg import SEG
|
||||
|
||||
class SearchChinese(SearchLanguage):
|
||||
lang = 'zh'
|
||||
|
||||
def init(self, options):
|
||||
print "reading Chiniese dictionary"
|
||||
self.seg = SEG()
|
||||
|
||||
def split(self, input):
|
||||
return self.seg.cut(input.encode("utf8"))
|
||||
|
||||
def word_filter(self, stemmed_word):
|
||||
return len(stemmed_word) > 1
|
|
@ -1096,6 +1096,7 @@ subrequest原理解析 (99%)
|
|||
location /world.htm {
|
||||
#content of world.htm: world
|
||||
}
|
||||
|
||||
访问/main.htm,将得到如下响应:
|
||||
|
||||
.. code:: c
|
|
@ -0,0 +1,346 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# sphinxdoc documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue Jul 19 09:39:30 2011.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
_exts = "../exts"
|
||||
TITLE = u"Nginx开发从入门到精通"
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
sys.path.append(os.path.abspath(_exts))
|
||||
extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'number_ref',
|
||||
'number_label', 'literal_include', 'block', 'image', 'basic', "latex_fix"]
|
||||
|
||||
#extensions.append('nohighlight')
|
||||
extensions.append('chinese_search')
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'Nginx开发从入门到精通'
|
||||
copyright = u'2012, taobao'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
language = "zh_CN"
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'book'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
html_theme_path = [_exts +"/theme"]
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
html_title = TITLE
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = "cover_sphinx.png"
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'nginx_bookdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'nginxbook.tex', TITLE,
|
||||
u'taobao server platform', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
latex_preamble = r"""
|
||||
% \pdfpagewidth 195mm
|
||||
% \pdfpageheight 271mm
|
||||
% \textwidth 6.0in
|
||||
% \textheight 8.8in
|
||||
% \oddsidemargin -0.1in
|
||||
% \evensidemargin -0.1in
|
||||
|
||||
\textwidth 6.8in
|
||||
\oddsidemargin -0.2in
|
||||
\evensidemargin -0.3in
|
||||
|
||||
\usepackage{pdfpages}
|
||||
\usepackage[BoldFont,CJKchecksingle]{xeCJK}
|
||||
\usepackage{float}
|
||||
\usepackage{ccaption}
|
||||
\usepackage{pifont}
|
||||
% \usepackage{fancybox}
|
||||
\usepackage{fontspec,xunicode,xltxtra}
|
||||
|
||||
\setsansfont{DejaVu Serif}
|
||||
% \setromanfont{DejaVu Sans Mono}
|
||||
\setmainfont{DejaVu Serif}
|
||||
\setmonofont{DejaVu Sans Mono}
|
||||
|
||||
% \setsansfont{WenQuanYi Micro Hei Light}
|
||||
% \setromanfont{WenQuanYi Micro Hei Light}
|
||||
% \setmainfont{WenQuanYi Micro Hei Light}
|
||||
% \setmonofont{WenQuanYi Micro Hei Mono Light}
|
||||
% STXihei
|
||||
\setCJKsansfont[BoldFont={SimSun},ItalicFont={SimSun}]{SimSun}
|
||||
\setCJKromanfont[BoldFont={SimSun},ItalicFont={SimSun}]{SimSun}
|
||||
\setCJKmainfont[BoldFont={SimSun},ItalicFont={SimSun}]{SimSun}
|
||||
\setCJKmonofont[BoldFont={SimSun},ItalicFont={SimSun}]{SimSun}
|
||||
|
||||
% \setCJKsansfont{Microsoft YaHei}
|
||||
% \setCJKromanfont{Microsoft YaHei}
|
||||
% \setCJKmainfont{Microsoft YaHei}
|
||||
% \setCJKmonofont{Microsoft YaHei}
|
||||
|
||||
% \CJKaddspaces\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}
|
||||
|
||||
\XeTeXlinebreaklocale "zh"
|
||||
\XeTeXlinebreakskip = 0pt plus 1pt
|
||||
\renewcommand{\baselinestretch}{1.3}
|
||||
\setcounter{tocdepth}{3}
|
||||
\captiontitlefont{\small\sffamily}
|
||||
\captiondelim{ - }
|
||||
\renewcommand\today{\number\year年\number\month月\number\day日}
|
||||
\makeatletter
|
||||
\renewcommand*\l@subsection{\@dottedtocline{2}{2.0em}{4.0em}}
|
||||
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3em}{5em}}
|
||||
\makeatother
|
||||
\titleformat{\chapter}[display]
|
||||
{\bfseries\Huge}
|
||||
{\filleft \Huge 第 \hspace{2 mm} \thechapter \hspace{4 mm} 章}
|
||||
{4ex}
|
||||
{\titlerule
|
||||
\vspace{1ex}%
|
||||
\filright}
|
||||
[\vspace{1ex}%
|
||||
\titlerule]
|
||||
%\definecolor{VerbatimBorderColor}{rgb}{0.2,0.2,0.2}
|
||||
\definecolor{VerbatimColor}{rgb}{0.95,0.95,0.95}
|
||||
""".decode("utf-8")
|
||||
|
||||
latex_elements = {
|
||||
"maketitle":ur"""
|
||||
\maketitle
|
||||
\renewcommand\contentsname{目 录}
|
||||
\renewcommand\partname{部分}
|
||||
\renewcommand{\chaptermark}[1]{\markboth{\textnormal{第 \thechapter\ 章 \hspace{4mm} #1}}{}}
|
||||
\renewcommand{\sectionmark}[1]{\markright{\textnormal{\thesection \hspace{2mm} #1}}{}}
|
||||
\renewcommand{\figurename}{\textsc{图}}
|
||||
\renewcommand{\tablename}{\textsc{表}}
|
||||
\chapter*{前言}
|
||||
\addcontentsline{toc}{chapter}{前言}
|
||||
""",
|
||||
"tableofcontents":ur"""
|
||||
\tableofcontents
|
||||
\fancyhead[LE,RO]{%s}
|
||||
""" % TITLE
|
||||
}
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'Nginx开发从入门到精通', u'Nginx开发从入门到精通 Documentation',
|
||||
[u'taobao'], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Epub output ---------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = u'Nginx开发从入门到精通'
|
||||
epub_author = u'taobao server platform'
|
||||
epub_publisher = u'taobao'
|
||||
epub_copyright = u'2012, taobao'
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
# or en if the language is not set.
|
||||
#epub_language = ''
|
||||
|
||||
# The scheme of the identifier. Typical schemes are ISBN or URL.
|
||||
#epub_scheme = ''
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#epub_uid = ''
|
||||
|
||||
# HTML files that should be inserted before the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_pre_files = []
|
||||
|
||||
# HTML files shat should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_post_files = []
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
#epub_exclude_files = []
|
||||
|
||||
# The depth of the table of contents in toc.ncx.
|
||||
#epub_tocdepth = 3
|
||||
|
||||
# Allow duplicate toc entries.
|
||||
#epub_tocdup = True
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,99 @@
|
|||
.. nginx_book documentation master file, created by
|
||||
sphinx-quickstart on Wed Feb 29 17:58:19 2012.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Nginx开发从入门到精通
|
||||
=============================
|
||||
|
||||
|
||||
缘起
|
||||
++++++
|
||||
|
||||
nginx由于出色的性能,在世界范围内受到了越来越多人的关注,在淘宝内部它更是被广泛的使用,众多的开发以及运维同学都迫切的想要了解nginx模块的开发以及它的内部原理,但是国内却没有一本关于这方面的书,源于此我们决定自己来写一本。本书的作者为淘宝核心系统服务器平台组的成员,本书写作的思路是从模块开发逐渐过渡到nginx原理剖析。书籍的内容会定期在这里更新,欢迎大家提出宝贵意见,不管是本书的内容问题,还是字词错误,都欢迎大家提交issue(章节标题的左侧有评注按钮),我们会及时的跟进。
|
||||
|
||||
.. topic:: 更新历史
|
||||
|
||||
.. csv-table::
|
||||
:header: 日期, 描述
|
||||
:widths: 20, 160
|
||||
:quote: $
|
||||
:delim: |
|
||||
|
||||
2012/03/01|创建目录大纲
|
||||
2012/03/28|增加了样章
|
||||
2012/05/25|更新样章
|
||||
2012/06/08|增加第5章
|
||||
2012/06/11|增加第4章
|
||||
2012/06/26|增加第6章(event module)
|
||||
2012/06/27|更新第5章部分内容
|
||||
2012/07/04|更新第6章event module部分内容
|
||||
2012/07/12|增加第12章(请求头读取,subrequest解析)
|
||||
2012/08/14|增加第2章(nginx基础架构及基础概念)
|
||||
2012/08/14|增加第2章(ngx_str_t数据结构介绍)
|
||||
2012/08/17|增加第7章(模块开发高级篇之变量)
|
||||
2012/08/25|增加第11章(nginx的启动阶段部分内容)
|
||||
2012/09/26|增加第2章(ngx_array_t,ngx_hash_t及ngx_pool_t介绍)
|
||||
2012/10/08|增加第11章(配置解析综述)
|
||||
2012/10/12|增加第2章(ngx_hash_wildcard_t,ngx_hash_combined_t及ngx_hash_keys_arrays_t介绍)
|
||||
2012/10/21|增加第2章(ngx_chain_t,ngx_list_t及ngx_buf_t介绍)
|
||||
2012/11/09|增加第12章(请求体的读取和丢弃解析)
|
||||
2012/11/24|更新第2章(ngx_buf_t的部分字段以及其他一些书写错误和表达)
|
||||
2012/12/18|更新第11章(解析http块)
|
||||
2012/12/10|增加第3章的内容
|
||||
2012/12/28|补充和完善了第3章的内容
|
||||
|
||||
版权申明
|
||||
++++++++++++
|
||||
|
||||
本书的著作权归作者淘宝核心系统服务器平台组成员所有。你可以:
|
||||
|
||||
- 下载、保存以及打印本书
|
||||
- 网络链接、转载本书的部分或者全部内容,但是必须在明显处提供读者访问本书发布网站的链接
|
||||
- 在你的程序中任意使用本书所附的程序代码,但是由本书的程序所引起的任何问题,作者不承担任何责任
|
||||
|
||||
你不可以:
|
||||
|
||||
- 以任何形式出售本书的电子版或者打印版
|
||||
- 擅自印刷、出版本书
|
||||
- 以纸媒出版为目的,改写、改编以及摘抄本书的内容
|
||||
|
||||
目录
|
||||
++++++
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
module_development.rst
|
||||
source_analysis.rst
|
||||
appendix_a.rst
|
||||
appendix_b.rst
|
||||
appendix_c.rst
|
||||
|
||||
团队成员
|
||||
++++++++++++
|
||||
|
||||
叔度 (http://blog.zhuzhaoyuan.com)
|
||||
|
||||
雕梁 (http://www.pagefault.info)
|
||||
|
||||
文景 (http://yaoweibin.cn)
|
||||
|
||||
李子 (http://blog.lifeibo.com)
|
||||
|
||||
卫越 (http://blog.sina.com.cn/u/1929617884)
|
||||
|
||||
袁茁 (http://yzprofile.me)
|
||||
|
||||
小熊 (http://dinic.iteye.com)
|
||||
|
||||
吉兆 (http://jizhao.blog.chinaunix.net)
|
||||
|
||||
静龙 (http://blog.csdn.net/fengmo_q)
|
||||
|
||||
竹权 (http://weibo.com/u/2199139545)
|
||||
|
||||
公远 (http://100continue.iteye.com/)
|
||||
|
||||
布可 (http://weibo.com/sifeierss)
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
:maxdepth: 3
|
||||
|
||||
chapter_01.rst
|
||||
chapter_02rst
|
||||
chapter_02.rst
|
||||
chapter_03.rst
|
||||
chapter_04.rst
|
||||
chapter_05.rst
|