Skip to content

Commit

Permalink
Render zh_CN docs under docs/zh/ directory, and add the language sele…
Browse files Browse the repository at this point in the history
…ctor. (#61)

Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow authored Jan 5, 2021
1 parent 5c9a222 commit 97f41ad
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{%- extends "!layout.html" %}

{#

This template exists as a way to implement a language menu just as what
"Read The Docs" does.

#}

{% block navigation %}
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
{% block menu %}
{#
The singlehtml builder doesn't handle this toctree call when the
toctree is empty. Skip building this for now.
#}
{% if 'singlehtml' not in builder %}
{% if 'zh' in pagename %}
{% set global_toc = toctree_for('zh/index',
maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=False,
titles_only=theme_titles_only|tobool) %}
{% else %}
{% set global_toc = toctree(maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=False,
titles_only=theme_titles_only|tobool) %}
{% endif %}
{% endif %}
{% if global_toc %}
{{ global_toc }}
{% else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>
{% endif %}
{% endblock %}
</div>
{% endblock %}

{% block footer %}
{{ footer }}

<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: latest
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>{{ _('Languages') }}</dt>
<dd><a href="{{ pathto('index.html', 1) }}">en</a></dd>
<dd><a href="{{ pathto('zh/index.html', 1) }}">zh_CN</a></dd>
</dl>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.autosectionlabel',
'sphinx_ext',
]

breathe_projects = {
Expand Down
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

.. toctree::
:hidden:

zh/index.rst
67 changes: 67 additions & 0 deletions docs/sphinx_ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sphinx
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.environment.adapters.toctree import TocTree

class TocTreeExt(TocTree):
def get_local_toctree_for(self, docname, builder, collapse, **kwargs):
''' Like `get_local_toctree` in `TocTree`, but don't generate
toctree for master_doc, rather, generate toctree for the
given doc.
'''
"""Return the global TOC nodetree."""
doctree = self.env.get_doctree(docname)
toctrees = [] # type: List[Element]
if 'includehidden' not in kwargs:
kwargs['includehidden'] = True
if 'maxdepth' not in kwargs:
kwargs['maxdepth'] = 0
kwargs['collapse'] = collapse
for toctreenode in doctree.traverse(addnodes.toctree):
toctree = self.resolve(docname, builder, toctreenode, prune=True, **kwargs)
if toctree:
toctrees.append(toctree)
if not toctrees:
return None
result = toctrees[0]
for toctree in toctrees[1:]:
result.extend(toctree.children)
return result

class StandaloneHTMLBuilderExt(StandaloneHTMLBuilder):
''' Extend the standard `StandaloneHTMLBuilder` with a `toctree_for` derivate in
context to creating toctrees for zh_CN documentations.
'''
def _get_local_toctree_ext(self, docname, collapse, **kwargs):
if 'includehidden' not in kwargs:
kwargs['includehidden'] = False
if kwargs.get('maxdepth') == '':
kwargs.pop('maxdepth')
return self.render_partial(TocTreeExt(self.env).get_local_toctree_for(
docname, self, collapse, **kwargs))['fragment']

def handle_page(self, *args, **kwargs):
self.globalcontext['toctree_for'] = lambda pagename, **kwargs: self._get_local_toctree_ext(pagename, **kwargs)
return super(StandaloneHTMLBuilderExt, self).handle_page(*args, **kwargs)

def setup(app):
app.add_builder(StandaloneHTMLBuilderExt, override=True)
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
2 changes: 2 additions & 0 deletions docs/zh/analytics_engine.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GraphScope Analytical Engine
============================
2 changes: 2 additions & 0 deletions docs/zh/deployment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
部署
====
2 changes: 2 additions & 0 deletions docs/zh/developer_guide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
开发者指南
==========
2 changes: 2 additions & 0 deletions docs/zh/getting_started.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
快速上手
========
48 changes: 48 additions & 0 deletions docs/zh/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. graphscope documentation master file, created by
sphinx-quickstart on Tue Aug 27 10:19:05 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
GraphScope: 一站式图计算系统
=========================

GraphScope 是阿里巴巴达摩院智能计算实验室研发并开源的一站式图计算平台。
依托于阿里海量数据和丰富场景,与达摩院的高水平研究,GraphScope致力于针对
实际生产中图计算的上述挑战,提供一站式高效的解决方案。

GraphScope 提供Python客户端,能十分方便的对接上下游工作流,具有一站式、
开发便捷、性能极致等特点。它具有高效的跨引擎内存管理,在业界首次支持Gremlin
分布式编译优化,同时支持算法的自动并行化和支持自动增量化处理动态图更新,
提供了企业级场景的极致性能。在阿里巴巴内部和外部的应用中,GraphScope已经
证明在多个关键互联网领域(如风控,电商推荐,广告,网络安全,知识图谱等)
实现重要的业务新价值。

GraphScope集合了达摩院的多项学术研究成果,其中的核心技术曾获得数据库领域
顶级学术会议 SIGMOD2017 最佳论文奖、VLDB2017 最佳演示奖、VLDB2020
最佳论文提名奖、世界人工智能创新大赛SAIL奖。GraphScope的交互查询引擎的
论文也已被 NSDI 2021录用,即将发表。还有其它围绕 GraphScope 的十多项
研究成果发表在领域顶级的学术会议或期刊上,如TODS、SIGMOD、VLDB、KDD等。

.. toctree::
:maxdepth: 2
:caption: Contents

installation
getting_started
deployment
loading_graph
interactive_engine
analytics_engine
learning_engine
developer_guide

.. toctree::
:maxdepth: 2
:caption: Reference

索引
====

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
2 changes: 2 additions & 0 deletions docs/zh/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
安装
====
2 changes: 2 additions & 0 deletions docs/zh/interactive_engine.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GraphScope Interactive Engine
============================
2 changes: 2 additions & 0 deletions docs/zh/learning_engine.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GraphScope Learning Engine
==========================
4 changes: 4 additions & 0 deletions docs/zh/loading_graph.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. _loading_graphs:

载图
====

0 comments on commit 97f41ad

Please sign in to comment.