From 5934950ce27a2f317f371444557c3509c1e0cf06 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sun, 2 Aug 2015 17:54:46 -0700 Subject: [PATCH] new doc --- doc/conf.py | 9 +++++---- doc/index.md | 4 ++-- doc/python_api.md | 2 +- doc/sphinx_util.py | 23 ++--------------------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index f3fff0919..64df5dba1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -21,7 +21,7 @@ curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) libpath = os.path.join(curr_path, '../wrapper/') sys.path.insert(0, os.path.join(curr_path, '../wrapper/')) sys.path.insert(0, curr_path) -from sphinx_util import MarkdownParser +from sphinx_util import MarkdownParser, AutoStructify # -- General configuration ------------------------------------------------ @@ -157,6 +157,7 @@ def generate_doxygen_xml(app): def setup(app): # Add hook for building doxygen xml when needed app.connect("builder-inited", generate_doxygen_xml) - - - + app.add_config_value('recommonmark_config', { + 'url_resolver': lambda url: github_doc_root + url, + }, True) + app.add_transform(AutoStructify) diff --git a/doc/index.md b/doc/index.md index 492f1e1eb..d209d95ba 100644 --- a/doc/index.md +++ b/doc/index.md @@ -3,7 +3,7 @@ Rabit Documentation rabit is a light weight library that provides a fault tolerant interface of Allreduce and Broadcast. It is designed to support easy implementations of distributed machine learning programs, many of which fall naturally under the Allreduce abstraction. The goal of rabit is to support **portable** , **scalable** and **reliable** distributed machine learning programs. API Documents -============= +------------- ```eval_rst .. toctree:: @@ -15,7 +15,7 @@ API Documents guide.md ``` Indices and tables -================== +------------------ ```eval_rst * :ref:`genindex` diff --git a/doc/python_api.md b/doc/python_api.md index 8ab786600..8a0eda921 100644 --- a/doc/python_api.md +++ b/doc/python_api.md @@ -8,4 +8,4 @@ This page contains document of python API of rabit. .. automodule:: rabit :members: :show-inheritance: -``` \ No newline at end of file +``` diff --git a/doc/sphinx_util.py b/doc/sphinx_util.py index 14545cb7d..0b5178630 100644 --- a/doc/sphinx_util.py +++ b/doc/sphinx_util.py @@ -13,24 +13,5 @@ if os.environ.get('READTHEDOCS', None) == 'True': sys.path.insert(0, os.path.abspath('..')) from recom import parser, transform -class MarkdownParser(docutils.parsers.Parser): - github_doc_root = None - - - def __init__(self): - self.parser = parser.CommonMarkParser() - - def parse(self, inputstring, document): - self.parser.parse(inputstring, document) - transform.AutoStructify.setup_url_resolver(resolve_url) - for trans in self.get_transforms(): - transform.AutoStructify(document).apply() - - def get_transforms(self): - return [transform.AutoStructify] - -def resolve_url(url): - if MarkdownParser.github_doc_root is None or url is None: - return url - else: - return MarkdownParser.github_doc_root + url +MarkdownParser = parser.CommonMarkParser +AutoStructify = transform.AutoStructify