Skip to content

Commit 5ce8e25

Browse files
committed
Updates to documentation theme.
1 parent 86f2fc3 commit 5ce8e25

File tree

19 files changed

+1209
-12
lines changed

19 files changed

+1209
-12
lines changed

docs/source/_static/logo.png

3.94 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="left-bar-other">
2+
<h3>Feedback</h3>
3+
<p class="feedback">Did you find this page useful? Do you have a suggestion? <a href="https://portal.aws.amazon.com/gp/aws/html-forms-controller/documentation/aws_doc_feedback_04?service_name=CfnCluster&guide_name=Reference&api_version={{ version }}&file_name={{ pagename }}">Give us feedback</a> or
4+
send us a <a href="https://github.com/awslabs/cfncluster">pull request</a> on GitHub.</p>
5+
</div>

docs/source/_templates/layout.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{%- extends "!layout.html" %}
2+
3+
{%- block nav_links %}
4+
<li><a href="{{ pathto(master_doc) }}">Home</a></li>
5+
<li><a href="https://forums.aws.amazon.com/forum.jspa?forumID=192">Forum</a></li>
6+
<li><a href="https://github.com/awslabs/cfncluster">GitHub</a></li>
7+
{%- endblock %}
8+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p class="logo left-bar-other">
2+
<a href="{{ pathto(master_doc) }}">
3+
<img class="logo" src="{{ pathto('_static/logo.png', 1) }}" alt="Logo" height="63" />
4+
</a>
5+
</p>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="left-bar-other">
2+
<h3>User Guide</h3>
3+
<p>First time using the AWS CLI? See the
4+
<a href="getting_started.html">Getting Started section</a> for
5+
help getting started.</p>
6+
</div>

docs/source/conf.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
16-
import os
15+
import sys, os
1716

1817
# If extensions (or modules to document with autodoc) are in another directory,
1918
# add these directories to sys.path here. If the directory is relative to the
2019
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
#sys.path.insert(0, os.path.abspath('.'))
20+
sys.path.insert(0, os.path.abspath('.'))
2221

2322
# -- General configuration ------------------------------------------------
2423

@@ -28,9 +27,7 @@
2827
# Add any Sphinx extension module names here, as strings. They can be
2928
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3029
# ones.
31-
extensions = [
32-
'sphinx.ext.todo',
33-
]
30+
extensions = []
3431

3532
# Add any paths that contain templates here, relative to this directory.
3633
templates_path = ['_templates']
@@ -53,9 +50,9 @@
5350
# built documents.
5451
#
5552
# The short X.Y version.
56-
version = 'v1.0.0b2'
53+
version = '1.0'
5754
# The full version, including alpha/beta/rc tags.
58-
release = 'v1.0.0b2'
55+
release = '1.0.0'
5956

6057
# The language for content autogenerated by Sphinx. Refer to documentation
6158
# for a list of supported languages.
@@ -87,7 +84,8 @@
8784
#show_authors = False
8885

8986
# The name of the Pygments (syntax highlighting) style to use.
90-
pygments_style = 'sphinx'
87+
pygments_style = 'guzzle_sphinx_theme.GuzzleStyle'
88+
#pygments_style = 'sphinx'
9189

9290
# A list of ignored prefixes for module index sorting.
9391
#modindex_common_prefix = []
@@ -103,7 +101,7 @@
103101

104102
# The theme to use for HTML and HTML Help pages. See the documentation for
105103
# a list of builtin themes.
106-
html_theme = 'default'
104+
#html_theme = 'default'
107105

108106
# Theme options are theme-specific and customize the look and feel of a theme
109107
# further. For a list of options available for each theme, see the
@@ -115,7 +113,7 @@
115113

116114
# The name for this set of Sphinx documents. If None, it defaults to
117115
# "<project> v<release> documentation".
118-
#html_title = None
116+
html_title = "CfnCluster %s" % release
119117

120118
# A shorter title for the navigation bar. Default is the same as html_title.
121119
#html_short_title = None
@@ -148,7 +146,13 @@
148146
#html_use_smartypants = True
149147

150148
# Custom sidebar templates, maps document names to template names.
151-
#html_sidebars = {}
149+
html_sidebars = {
150+
'**': ['sidebarlogo.html',
151+
'localtoc.html',
152+
'searchbox.html',
153+
'feedback.html',
154+
'userguide.html']
155+
}
152156

153157
# Additional templates that should be rendered to pages, maps page names to
154158
# template names.
@@ -183,6 +187,27 @@
183187
# Output file base name for HTML help builder.
184188
htmlhelp_basename = 'cfnclusterdoc'
185189

190+
html_translator_class = 'guzzle_sphinx_theme.HTMLTranslator'
191+
p = os.path.abspath('.')
192+
p = os.path.join(p, 'guzzle_sphinx_theme')
193+
html_theme_path = [p]
194+
html_theme = 'guzzle_sphinx_theme'
195+
# Register the theme as an extension to generate a sitemap.xml
196+
extensions.append("guzzle_sphinx_theme")
197+
198+
html_theme_options = {
199+
# Set the name of the project to appear in the nav menu
200+
"project_nav_name": "CfnCluster",
201+
# Set your GitHub user and repo to enable GitHub stars links
202+
"github_user": "awslabs",
203+
"github_repo": "cfncluster",
204+
# Set to true to bind left and right key events to turn the page
205+
"bind_key_events": False,
206+
# Specify a base_url used to generate sitemap.xml links. If not
207+
# specified, then no sitemap will be built.
208+
"base_url": "http://cfncluster.readthedocs.org/lastet/"
209+
}
210+
186211

187212
# -- Options for LaTeX output ---------------------------------------------
188213

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013 Michael Dowling <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
"""Sphinx Guzzle theme."""
2+
3+
import os
4+
import xml.etree.ElementTree as ET
5+
6+
from docutils import nodes
7+
from sphinx.locale import admonitionlabels
8+
from sphinx.writers.html import HTMLTranslator as SphinxHTMLTranslator
9+
10+
from pygments.style import Style
11+
from pygments.token import Keyword, Name, Comment, String, Error, \
12+
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
13+
14+
15+
def setup(app):
16+
"""Setup conntects events to the sitemap builder"""
17+
app.connect('html-page-context', add_html_link)
18+
app.connect('build-finished', create_sitemap)
19+
app.sitemap_links = []
20+
21+
22+
def add_html_link(app, pagename, templatename, context, doctree):
23+
"""As each page is built, collect page names for the sitemap"""
24+
base_url = app.config['html_theme_options'].get('base_url', '')
25+
if base_url:
26+
app.sitemap_links.append(base_url + pagename + ".html")
27+
28+
29+
def create_sitemap(app, exception):
30+
"""Generates the sitemap.xml from the collected HTML page links"""
31+
if (not app.config['html_theme_options'].get('base_url', '') or
32+
exception is not None or
33+
not app.sitemap_links):
34+
return
35+
36+
filename = app.outdir + "/sitemap.xml"
37+
print("Generating sitemap.xml in %s" % filename)
38+
39+
root = ET.Element("urlset")
40+
root.set("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")
41+
42+
for link in app.sitemap_links:
43+
url = ET.SubElement(root, "url")
44+
ET.SubElement(url, "loc").text = link
45+
46+
ET.ElementTree(root).write(filename)
47+
48+
49+
def html_theme_path():
50+
return [os.path.dirname(os.path.abspath(__file__))]
51+
52+
53+
class HTMLTranslator(SphinxHTMLTranslator):
54+
"""
55+
Handle translating to bootstrap structure.
56+
"""
57+
def visit_table(self, node, name=''):
58+
"""
59+
Override docutils default table formatter to not include a border
60+
and to use Bootstrap CSS
61+
See: http://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/writers/html4css1/__init__.py#l1550
62+
"""
63+
self.context.append(self.compact_p)
64+
self.compact_p = True
65+
classes = ' '.join(['table', 'table-bordered',
66+
self.settings.table_style]).strip()
67+
self.body.append(
68+
self.starttag(node, 'table', CLASS=classes))
69+
70+
def depart_table(self, node):
71+
"""
72+
This needs overridin' too
73+
"""
74+
self.compact_p = self.context.pop()
75+
self.body.append('</table>\n')
76+
77+
78+
class GuzzleStyle(Style):
79+
background_color = "#f8f8f8"
80+
default_style = ""
81+
82+
styles = {
83+
# No corresponding class for the following:
84+
#Text: "", # class: ''
85+
Whitespace: "underline #f8f8f8", # class: 'w'
86+
Error: "#a40000 border:#ef2929", # class: 'err'
87+
Other: "#000000", # class 'x'
88+
89+
Comment: "italic #8f5902", # class: 'c'
90+
Comment.Preproc: "noitalic", # class: 'cp'
91+
92+
Keyword: "bold #004461", # class: 'k'
93+
Keyword.Constant: "bold #004461", # class: 'kc'
94+
Keyword.Declaration: "bold #004461", # class: 'kd'
95+
Keyword.Namespace: "bold #004461", # class: 'kn'
96+
Keyword.Pseudo: "bold #004461", # class: 'kp'
97+
Keyword.Reserved: "bold #004461", # class: 'kr'
98+
Keyword.Type: "bold #004461", # class: 'kt'
99+
100+
Operator: "#582800", # class: 'o'
101+
Operator.Word: "bold #004461", # class: 'ow' - like keywords
102+
103+
Punctuation: "bold #000000", # class: 'p'
104+
105+
# because special names such as Name.Class, Name.Function, etc.
106+
# are not recognized as such later in the parsing, we choose them
107+
# to look the same as ordinary variables.
108+
Name: "#000000", # class: 'n'
109+
Name.Attribute: "#006EC4", # class: 'na' - to be revised
110+
Name.Builtin: "#004461", # class: 'nb'
111+
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
112+
Name.Class: "#000000", # class: 'nc' - to be revised
113+
Name.Constant: "#000000", # class: 'no' - to be revised
114+
Name.Decorator: "#888", # class: 'nd' - to be revised
115+
Name.Entity: "#ce5c00", # class: 'ni'
116+
Name.Exception: "bold #cc0000", # class: 'ne'
117+
Name.Function: "#000000", # class: 'nf'
118+
Name.Property: "#000000", # class: 'py'
119+
Name.Label: "#f57900", # class: 'nl'
120+
Name.Namespace: "#000000", # class: 'nn' - to be revised
121+
Name.Other: "#000000", # class: 'nx'
122+
Name.Tag: "bold #004461", # class: 'nt' - like a keyword
123+
Name.Variable: "#000000", # class: 'nv' - to be revised
124+
Name.Variable.Class: "#000000", # class: 'vc' - to be revised
125+
Name.Variable.Global: "#000000", # class: 'vg' - to be revised
126+
Name.Variable.Instance: "#000000", # class: 'vi' - to be revised
127+
128+
Number: "#990000", # class: 'm'
129+
130+
Literal: "#000000", # class: 'l'
131+
Literal.Date: "#000000", # class: 'ld'
132+
133+
String: "#4e9a06", # class: 's'
134+
String.Backtick: "#4e9a06", # class: 'sb'
135+
String.Char: "#4e9a06", # class: 'sc'
136+
String.Doc: "italic #8f5902", # class: 'sd' - like a comment
137+
String.Double: "#4e9a06", # class: 's2'
138+
String.Escape: "#4e9a06", # class: 'se'
139+
String.Heredoc: "#4e9a06", # class: 'sh'
140+
String.Interpol: "#4e9a06", # class: 'si'
141+
String.Other: "#4e9a06", # class: 'sx'
142+
String.Regex: "#4e9a06", # class: 'sr'
143+
String.Single: "#4e9a06", # class: 's1'
144+
String.Symbol: "#4e9a06", # class: 'ss'
145+
146+
Generic: "#000000", # class: 'g'
147+
Generic.Deleted: "#a40000", # class: 'gd'
148+
Generic.Emph: "italic #000000", # class: 'ge'
149+
Generic.Error: "#ef2929", # class: 'gr'
150+
Generic.Heading: "bold #000080", # class: 'gh'
151+
Generic.Inserted: "#00A000", # class: 'gi'
152+
Generic.Output: "#888", # class: 'go'
153+
Generic.Prompt: "#745334", # class: 'gp'
154+
Generic.Strong: "bold #000000", # class: 'gs'
155+
Generic.Subheading: "bold #800080", # class: 'gu'
156+
Generic.Traceback: "bold #a40000", # class: 'gt'
157+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% if theme_disqus_comments_shortname %}
2+
<div id="comments">
3+
<div id="disqus_thread"></div>
4+
<script type="text/javascript">
5+
var disqus_shortname = '{{ theme_disqus_comments_shortname }}';
6+
var disqus_identifier = '{{ pagename }}';
7+
(function() {
8+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
9+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
10+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
11+
})();
12+
</script>
13+
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
14+
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
15+
</div>
16+
{% endif %}

0 commit comments

Comments
 (0)