Skip to content

Commit ad59085

Browse files
committed
1. theme related static resources
2. add unit test library 3. remove useless comments 4. use js & css libs on the CDN
1 parent 9619015 commit ad59085

File tree

9 files changed

+812
-9
lines changed

9 files changed

+812
-9
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ before_install:
5050
fi
5151
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi
5252
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
53-
- pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy
53+
- pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy sphinx_rtd_theme
5454
script:
5555
- paddle/scripts/travis/main.sh
5656
notifications:

doc/conf.py.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AutoStructify = transform.AutoStructify
2323
# documentation root, use os.path.abspath to make it absolute, like shown here.
2424
sys.path.insert(0, '@PROJ_ROOT@/python')
2525

26-
templates_path = ["@PROJ_ROOT@/doc/templates"]
26+
templates_path = ["@PROJ_ROOT@/doc_theme/templates"]
2727

2828
# -- General configuration ------------------------------------------------
2929

@@ -113,13 +113,12 @@ todo_include_todos = False
113113

114114
# The theme to use for HTML and HTML Help pages. See the documentation for
115115
# a list of builtin themes.
116-
#html_theme = 'sphinx_rtd_theme'
117-
html_theme = 'classic'
116+
html_theme = 'sphinx_rtd_theme'
118117

119118
# Add any paths that contain custom static files (such as style sheets) here,
120119
# relative to this directory. They are copied after the builtin static files,
121120
# so a file named "default.css" will overwrite the builtin "default.css".
122-
html_static_path = ['_static']
121+
html_static_path = ['@PROJ_ROOT@/doc_theme/static']
123122

124123
# Output file base name for HTML help builder.
125124
htmlhelp_basename = project + 'doc'

doc_cn/conf.py.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ AutoStructify = transform.AutoStructify
2222
# add these directories to sys.path here. If the directory is relative to the
2323
# documentation root, use os.path.abspath to make it absolute, like shown here.
2424
sys.path.insert(0, '@PROJ_ROOT@/python')
25-
templates_path = ["@PROJ_ROOT@/doc/templates"]
25+
templates_path = ["@PROJ_ROOT@/doc_theme/templates"]
2626

2727
# -- General configuration ------------------------------------------------
2828

@@ -112,12 +112,12 @@ todo_include_todos = False
112112

113113
# The theme to use for HTML and HTML Help pages. See the documentation for
114114
# a list of builtin themes.
115-
#html_theme = 'sphinx_rtd_theme' # sphinx_rtd_theme will cause table bad style
116-
html_theme = 'classic'
115+
html_theme = 'sphinx_rtd_theme'
116+
117117
# Add any paths that contain custom static files (such as style sheets) here,
118118
# relative to this directory. They are copied after the builtin static files,
119119
# so a file named "default.css" will overwrite the builtin "default.css".
120-
html_static_path = ['_static']
120+
html_static_path = ['@PROJ_ROOT@/doc_theme/static']
121121

122122
# Output file base name for HTML help builder.
123123
htmlhelp_basename = project + 'doc'

doc_theme/static/css/override.css

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.

doc_theme/static/images/PP_w.png

3.11 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$(document).ready(function(){
2+
$('.local-toc').on('click' ,'a.reference.internal', function (){
3+
$('.local-toc li.active').removeClass('active');
4+
$(this).parent('li').addClass('active');
5+
});
6+
7+
if ($('.local-toc a:visible').length) {
8+
$('.local-toc > ul').addClass('nav nav-stacked');
9+
$('#doc-content').scrollspy({
10+
target: '.local-toc'
11+
});
12+
$('.local-toc').perfectScrollbar();
13+
} else {
14+
$('.doc-content-wrap').css('margin-left', '-=50px');
15+
$('.local-toc').remove();
16+
}
17+
18+
if (!$('.doc-menu-vertical > ul > li.current > ul').length) {
19+
$('.doc-content-wrap').css('margin-left', '-=240px');
20+
$('.doc-menu-vertical').remove();
21+
$('.local-toc').css('left', '0');
22+
}
23+
24+
$('.doc-menu-vertical .toctree-l2').each(function (i, e){
25+
$(e).toggleClass('has-child', !!$(e).find('ul').length);
26+
});
27+
28+
$('.doc-menu-vertical').find('li.current').last().addClass('active');
29+
30+
$('.doc-menu-vertical').perfectScrollbar();
31+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{# Support for Sphinx 1.3+ page_source_suffix, but don't break old builds. #}
2+
3+
{% if page_source_suffix %}
4+
{% set suffix = page_source_suffix %}
5+
{% else %}
6+
{% set suffix = source_suffix %}
7+
{% endif %}
8+
9+
{% if meta is defined and 'github_url' in meta %}
10+
{% set display_github = True %}
11+
{% endif %}
12+
13+
{% if meta is defined and 'bitbucket_url' in meta %}
14+
{% set display_bitbucket = True %}
15+
{% endif %}
16+
17+
<div role="navigation" aria-label="breadcrumbs navigation">
18+
<ul class="wy-breadcrumbs">
19+
{% for doc in parents %}
20+
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> > </li>
21+
{% endfor %}
22+
<li>{{ title }}</li>
23+
</ul>
24+
</div>

doc_theme/templates/layout.html

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
{# TEMPLATE VAR SETTINGS #}
2+
{%- set url_root = pathto('', 1) %}
3+
{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
4+
{%- if not embedded and docstitle %}
5+
{%- set titlesuffix = " &mdash; "|safe + docstitle|e %}
6+
{%- else %}
7+
{%- set titlesuffix = "" %}
8+
{%- endif %}
9+
10+
<!DOCTYPE html>
11+
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
12+
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
13+
<head>
14+
<meta charset="utf-8">
15+
{{ metatags }}
16+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
17+
{% block htmltitle %}
18+
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
19+
{% endblock %}
20+
21+
{# FAVICON #}
22+
{% if favicon %}
23+
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
24+
{% endif %}
25+
26+
{# CSS #}
27+
28+
{# OPENSEARCH #}
29+
{% if not embedded %}
30+
{% if use_opensearch %}
31+
<link rel="search" type="application/opensearchdescription+xml" title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}" href="{{ pathto('_static/opensearch.xml', 1) }}"/>
32+
{% endif %}
33+
34+
{% endif %}
35+
36+
{# RTD hosts this file, so just load on non RTD builds #}
37+
{% if not READTHEDOCS %}
38+
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
39+
{% endif %}
40+
41+
{% for cssfile in css_files %}
42+
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
43+
{% endfor %}
44+
{% for cssfile in extra_css_files %}
45+
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
46+
{% endfor %}
47+
48+
{%- block linktags %}
49+
{%- if hasdoc('about') %}
50+
<link rel="author" title="{{ _('About these documents') }}"
51+
href="{{ pathto('about') }}"/>
52+
{%- endif %}
53+
{%- if hasdoc('genindex') %}
54+
<link rel="index" title="{{ _('Index') }}"
55+
href="{{ pathto('genindex') }}"/>
56+
{%- endif %}
57+
{%- if hasdoc('search') %}
58+
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}"/>
59+
{%- endif %}
60+
{%- if hasdoc('copyright') %}
61+
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}"/>
62+
{%- endif %}
63+
<link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}"/>
64+
{%- if parents %}
65+
<link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}"/>
66+
{%- endif %}
67+
{%- if next %}
68+
<link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}"/>
69+
{%- endif %}
70+
{%- if prev %}
71+
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}"/>
72+
{%- endif %}
73+
{%- endblock %}
74+
{%- block extrahead %}
75+
76+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
77+
<link rel="stylesheet" href="{{pathto('_static/css/override.css', 1)}}" type="text/css" />
78+
<script>
79+
var _hmt = _hmt || [];
80+
(function() {
81+
var hm = document.createElement("script");
82+
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
83+
var s = document.getElementsByTagName("script")[0];
84+
s.parentNode.insertBefore(hm, s);
85+
})();
86+
</script>
87+
88+
{% endblock %}
89+
90+
{# Keep modernizr in head - http://modernizr.com/docs/#installing #}
91+
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script>
92+
93+
</head>
94+
95+
<body class="wy-body-for-nav" role="document">
96+
97+
{% block extrabody %}
98+
<header class="site-header">
99+
<div class="site-logo">
100+
<a href="/"><img src="{{pathto('_static/images/PP_w.png', 1)}}"></a>
101+
</div>
102+
<div class="site-nav-links">
103+
<div class="site-menu">
104+
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
105+
<div class="language-switcher dropdown">
106+
<a type="button" data-toggle="dropdown">
107+
<span>English</span>
108+
<i class="fa fa-angle-up"></i>
109+
<i class="fa fa-angle-down"></i>
110+
</a>
111+
<ul class="dropdown-menu">
112+
<li><a href="/doc_cn">中文</a></li>
113+
<li><a href="/doc">English</a></li>
114+
</ul>
115+
</div>
116+
<ul class="site-page-links">
117+
<li><a>Home</a></li>
118+
<li><a>Get Started</a></li>
119+
<li class="active"><a>Documentation</a></li>
120+
<li><a>About Us</a></li>
121+
</ul>
122+
</div>
123+
<div class="doc-module">
124+
{%set modules = toctree(maxdepth=0, collapse=False, titles_only=True)%}
125+
{{modules}}
126+
{% include "searchbox.html" %}
127+
</div>
128+
</div>
129+
</header>
130+
{% endblock %}
131+
<div class="main-content-wrap">
132+
133+
{# SIDE NAV, TOGGLES ON MOBILE #}
134+
<nav class="doc-menu-vertical" role="navigation">
135+
{% block menu %}
136+
{% set toctree = toctree(maxdepth=-1, collapse=False,titles_only=True, includehidden=True) %}
137+
{{ toctree }}
138+
{% endblock %}
139+
</nav>
140+
{% if toc %}
141+
<nav class="local-toc">{{ toc }}</nav>
142+
{% endif %}
143+
<section class="doc-content-wrap">
144+
145+
{% include "breadcrumbs.html" %}
146+
{# PAGE CONTENT #}
147+
<div class="wy-nav-content" id="doc-content">
148+
<div class="rst-content">
149+
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
150+
<div itemprop="articleBody">
151+
{% block body %}{% endblock %}
152+
</div>
153+
</div>
154+
{% include "footer.html" %}
155+
</div>
156+
</div>
157+
158+
</section>
159+
160+
</div>
161+
{% include "versions.html" %}
162+
163+
{% if not embedded %}
164+
165+
<script type="text/javascript">
166+
var DOCUMENTATION_OPTIONS = {
167+
URL_ROOT:'{{ url_root }}',
168+
VERSION:'{{ release|e }}',
169+
COLLAPSE_INDEX:false,
170+
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
171+
HAS_SOURCE: {{ has_source|lower }}
172+
};
173+
</script>
174+
{%- for scriptfile in script_files %}
175+
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
176+
{%- endfor %}
177+
178+
{% endif %}
179+
180+
{# RTD hosts this file, so just load on non RTD builds #}
181+
{% if not READTHEDOCS %}
182+
<script type="text/javascript" src="{{ pathto('_static/js/theme.js', 1) }}"></script>
183+
{% endif %}
184+
185+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
186+
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
187+
<script src="{{ pathto('_static/js/paddle_doc_init.js', 1) }}"></script>
188+
{%- block footer %} {% endblock %}
189+
190+
</body>
191+
</html>

doc_theme/templates/search.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{#
2+
basic/search.html
3+
~~~~~~~~~~~~~~~~~
4+
5+
Template for the search page.
6+
7+
:copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS.
8+
:license: BSD, see LICENSE for details.
9+
#}
10+
{%- extends "layout.html" %}
11+
{% set title = _('Search') %}
12+
{% set script_files = script_files + ['_static/searchtools.js'] %}
13+
{% block footer %}
14+
<script type="text/javascript">
15+
jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); });
16+
jQuery('.doc-content-wrap > div[role="navigation"]').remove();
17+
jQuery('.doc-content-wrap').css('padding-top', 0);
18+
</script>
19+
{# this is used when loading the search index using $.ajax fails,
20+
such as on Chrome for documents on localhost #}
21+
<script type="text/javascript" id="searchindexloader"></script>
22+
{{ super() }}
23+
{% endblock %}
24+
{% block body %}
25+
<noscript>
26+
<div id="fallback" class="admonition warning">
27+
<p class="last">
28+
{% trans %}Please activate JavaScript to enable the search
29+
functionality.{% endtrans %}
30+
</p>
31+
</div>
32+
</noscript>
33+
34+
{% if search_performed %}
35+
<h2>{{ _('Search Results') }}</h2>
36+
{% if not search_results %}
37+
<p>{{ _('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.') }}</p>
38+
{% endif %}
39+
{% endif %}
40+
<div id="search-results">
41+
{% if search_results %}
42+
<ul>
43+
{% for href, caption, context in search_results %}
44+
<li>
45+
<a href="{{ pathto(item.href) }}">{{ caption }}</a>
46+
<p class="context">{{ context|e }}</p>
47+
</li>
48+
{% endfor %}
49+
</ul>
50+
{% endif %}
51+
</div>
52+
{% endblock %}

0 commit comments

Comments
 (0)