Skip to content

Commit 2f15fd2

Browse files
committed
adding buildme for docs and adding a template from sphinx
1 parent 4662fae commit 2f15fd2

File tree

4 files changed

+237
-0
lines changed

4 files changed

+237
-0
lines changed

docs/_templates/basic/layout.html

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{#
2+
basic/layout.html
3+
~~~~~~~~~~~~~~~~~
4+
5+
Master layout template for Sphinx themes.
6+
7+
NOTE: This is copy pasted from Sphinx to DeepDiff and
8+
then the 3 lines related to Canonical links are removed
9+
to make sure we generate the proper canonical links via
10+
the alabaster team.
11+
12+
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
13+
:license: BSD, see LICENSE for details.
14+
#}
15+
{%- block doctype -%}{%- if html5_doctype %}
16+
<!DOCTYPE html>
17+
{%- else %}
18+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
19+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
20+
{%- endif %}{%- endblock %}
21+
{%- set reldelim1 = reldelim1 is not defined and ' &#187;' or reldelim1 %}
22+
{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
23+
{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
24+
(sidebars != []) %}
25+
{%- set url_root = pathto('', 1) %}
26+
{# XXX necessary? #}
27+
{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
28+
{%- if not embedded and docstitle %}
29+
{%- set titlesuffix = " &#8212; "|safe + docstitle|e %}
30+
{%- else %}
31+
{%- set titlesuffix = "" %}
32+
{%- endif %}
33+
34+
{%- macro relbar() %}
35+
<div class="related" role="navigation" aria-label="related navigation">
36+
<h3>{{ _('Navigation') }}</h3>
37+
<ul>
38+
{%- for rellink in rellinks %}
39+
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
40+
<a href="{{ pathto(rellink[0])|e }}" title="{{ rellink[1]|striptags|e }}"
41+
{{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
42+
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
43+
{%- endfor %}
44+
{%- block rootrellink %}
45+
<li class="nav-item nav-item-0"><a href="{{ pathto(master_doc)|e }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
46+
{%- endblock %}
47+
{%- for parent in parents %}
48+
<li class="nav-item nav-item-{{ loop.index }}"><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
49+
{%- endfor %}
50+
<li class="nav-item nav-item-this"><a href="{{ link|e }}">{{ title }}</a></li>
51+
{%- block relbaritems %} {% endblock %}
52+
</ul>
53+
</div>
54+
{%- endmacro %}
55+
56+
{%- macro sidebar() %}
57+
{%- if render_sidebar %}
58+
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
59+
<div class="sphinxsidebarwrapper">
60+
{%- block sidebarlogo %}
61+
{%- if logo %}
62+
<p class="logo"><a href="{{ pathto(master_doc)|e }}">
63+
<img class="logo" src="{{ pathto('_static/' + logo, 1)|e }}" alt="Logo"/>
64+
</a></p>
65+
{%- endif %}
66+
{%- endblock %}
67+
{%- if sidebars != None %}
68+
{#- new style sidebar: explicitly include/exclude templates #}
69+
{%- for sidebartemplate in sidebars %}
70+
{%- include sidebartemplate %}
71+
{%- endfor %}
72+
{%- else %}
73+
{#- old style sidebars: using blocks -- should be deprecated #}
74+
{%- block sidebartoc %}
75+
{%- include "localtoc.html" %}
76+
{%- endblock %}
77+
{%- block sidebarrel %}
78+
{%- include "relations.html" %}
79+
{%- endblock %}
80+
{%- block sidebarsourcelink %}
81+
{%- include "sourcelink.html" %}
82+
{%- endblock %}
83+
{%- if customsidebar %}
84+
{%- include customsidebar %}
85+
{%- endif %}
86+
{%- block sidebarsearch %}
87+
{%- include "searchbox.html" %}
88+
{%- endblock %}
89+
{%- endif %}
90+
</div>
91+
</div>
92+
{%- endif %}
93+
{%- endmacro %}
94+
95+
{%- macro script() %}
96+
<script id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
97+
{%- for js in script_files %}
98+
{{ js_tag(js) }}
99+
{%- endfor %}
100+
{%- endmacro %}
101+
102+
{%- macro css() %}
103+
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1)|e }}" type="text/css" />
104+
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
105+
{%- for css in css_files %}
106+
{%- if css|attr("filename") %}
107+
{{ css_tag(css) }}
108+
{%- else %}
109+
<link rel="stylesheet" href="{{ pathto(css, 1)|e }}" type="text/css" />
110+
{%- endif %}
111+
{%- endfor %}
112+
{%- endmacro %}
113+
114+
{%- if html_tag %}
115+
{{ html_tag }}
116+
{%- else %}
117+
<html{% if not html5_doctype %} xmlns="http://www.w3.org/1999/xhtml"{% endif %}{% if language is not none %} lang="{{ language }}"{% endif %}>
118+
{%- endif %}
119+
<head>
120+
{%- if not html5_doctype and not skip_ua_compatible %}
121+
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
122+
{%- endif %}
123+
{%- if use_meta_charset or html5_doctype %}
124+
<meta charset="{{ encoding }}" />
125+
{%- else %}
126+
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
127+
{%- endif %}
128+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
129+
{{- metatags }}
130+
{%- block htmltitle %}
131+
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
132+
{%- endblock %}
133+
{%- block css %}
134+
{{- css() }}
135+
{%- endblock %}
136+
{%- if not embedded %}
137+
{%- block scripts %}
138+
{{- script() }}
139+
{%- endblock %}
140+
{%- if use_opensearch %}
141+
<link rel="search" type="application/opensearchdescription+xml"
142+
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
143+
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
144+
{%- endif %}
145+
{%- if favicon %}
146+
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1)|e }}"/>
147+
{%- endif %}
148+
{%- endif %}
149+
{%- block linktags %}
150+
{%- if hasdoc('about') %}
151+
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
152+
{%- endif %}
153+
{%- if hasdoc('genindex') %}
154+
<link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
155+
{%- endif %}
156+
{%- if hasdoc('search') %}
157+
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
158+
{%- endif %}
159+
{%- if hasdoc('copyright') %}
160+
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
161+
{%- endif %}
162+
{%- if next %}
163+
<link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}" />
164+
{%- endif %}
165+
{%- if prev %}
166+
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
167+
{%- endif %}
168+
{%- endblock %}
169+
{%- block extrahead %} {% endblock %}
170+
</head>
171+
{%- block body_tag %}<body>{% endblock %}
172+
{%- block header %}{% endblock %}
173+
174+
{%- block relbar1 %}{{ relbar() }}{% endblock %}
175+
176+
{%- block content %}
177+
{%- block sidebar1 %} {# possible location for sidebar #} {% endblock %}
178+
179+
<div class="document">
180+
{%- block document %}
181+
<div class="documentwrapper">
182+
{%- if render_sidebar %}
183+
<div class="bodywrapper">
184+
{%- endif %}
185+
<div class="body" role="main">
186+
{% block body %} {% endblock %}
187+
<div class="clearer"></div>
188+
</div>
189+
{%- if render_sidebar %}
190+
</div>
191+
{%- endif %}
192+
</div>
193+
{%- endblock %}
194+
195+
{%- block sidebar2 %}{{ sidebar() }}{% endblock %}
196+
<div class="clearer"></div>
197+
</div>
198+
{%- endblock %}
199+
200+
{%- block relbar2 %}{{ relbar() }}{% endblock %}
201+
202+
{%- block footer %}
203+
<div class="footer" role="contentinfo">
204+
{%- if show_copyright %}
205+
{%- if hasdoc('copyright') %}
206+
{% trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
207+
{%- else %}
208+
{% trans copyright=copyright|e %}&#169; Copyright {{ copyright }}.{% endtrans %}
209+
{%- endif %}
210+
{%- endif %}
211+
{%- if last_updated %}
212+
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
213+
{%- endif %}
214+
{%- if show_sphinx %}
215+
{% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
216+
{%- endif %}
217+
</div>
218+
{%- endblock %}
219+
</body>
220+
</html>

docs/buildme.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def __init__(self):
3333
def on_any_event(self, event):
3434
load_dotenv(override=True)
3535
build_path = os.environ.get('BUILD_PATH', '_build')
36+
doc_version = os.environ.get('DOC_VERSION', '')
37+
if not build_path.endswith('/'):
38+
build_path = build_path + '/'
39+
build_path += doc_version
3640
if event is None:
3741
print('initial build')
3842
else:

docs/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import sys
1616
import os
17+
from dotenv import load_dotenv
1718

1819
# If extensions (or modules to document with autodoc) are in another directory,
1920
# add these directories to sys.path here. If the directory is relative to the
@@ -32,6 +33,7 @@
3233
extensions = [
3334
'sphinx.ext.autodoc',
3435
'sphinx.ext.doctest',
36+
'sphinx_sitemap',
3537
]
3638

3739
# Add any paths that contain templates here, relative to this directory.
@@ -62,6 +64,10 @@
6264
# The full version, including alpha/beta/rc tags.
6365
release = '5.0.0'
6466

67+
load_dotenv(override=True)
68+
DOC_VERSION = os.environ.get('DOC_VERSION', version)
69+
70+
6571
# The language for content autogenerated by Sphinx. Refer to documentation
6672
# for a list of supported languages.
6773
#
@@ -133,6 +139,7 @@
133139
'github_user': 'seperman',
134140
'github_count': True,
135141
'font_family': 'Open Sans',
142+
'canonical_url': 'https://zepworks.com/deepdiff/current/',
136143
}
137144

138145
# Add any paths that contain custom themes here, relative to this directory.
@@ -222,6 +229,11 @@
222229
# Output file base name for HTML help builder.
223230
htmlhelp_basename = 'DeepDiffdoc'
224231

232+
# Sitemap settings:
233+
234+
html_baseurl = f'https://zepworks.com/deepdiff/{DOC_VERSION}'
235+
sitemap_url_scheme = "{link}"
236+
225237
# -- Options for LaTeX output ---------------------------------------------
226238

227239
latex_elements = {

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ pytest-cov==2.8.1
1010
python-dotenv==0.13.0
1111
watchdog==0.10.2
1212
Sphinx==3.1.1
13+
sphinx-sitemap==2.1.0

0 commit comments

Comments
 (0)