openstackdocstheme integration

changes the output to be compatible with the new
openstackdocs theme

Change-Id: I10d90ac2f702153508bc6e607ed451c089276a4d
This commit is contained in:
Graham Hayes 2016-05-28 13:41:27 +02:00
parent b100d1542f
commit 916db5d19b
9 changed files with 94 additions and 56 deletions

View File

@ -30,6 +30,9 @@ from os_api_ref.http_codes import HTTPResponseCodeDirective
__version__ = pbr.version.VersionInfo(
'os_api_ref').version_string()
# This is to allow for a graceful swap from oslosphinx to openstackdocstheme
THEME = 'openstackdocstheme'
"""This provides a sphinx extension able to create the HTML needed
for the api-ref website.
@ -464,15 +467,22 @@ class RestParametersDirective(Table):
def rest_method_html(self, node):
tmpl = """
<div class="row operation-grp %(css_classes)s">
<div class="col-md-1 operation">
<div class="operation-grp %(css_classes)s">
<div class="row">
<div class="col-md-2">
<div class="operation">
<a name="%(target)s" class="operation-anchor" href="#%(target)s">
<span class="glyphicon glyphicon-link"></span></a>
<span class="label label-%(method)s">%(method)s</span>
</div>
<div class="row col-md-9">
<div class="row col-md-12">%(url)s</div>
<div class="row col-md-12"><p class="url-subtitle">%(desc)s</p></div>
</div>
<div class="col-md-9">
<div class="row">
<div class="endpoint-container">
<div class="row col-md-12">%(url)s</div>
<div class="row col-md-12"><p class="url-subtitle">%(desc)s</p></div>
</div>
</div>
</div>
<div class="col-md-1">
<button
@ -482,6 +492,7 @@ def rest_method_html(self, node):
id="%(target)s-detail-btn"
>detail</button>
</div>
</div>
</div>"""
node['url'] = node['url'].replace(
@ -563,23 +574,28 @@ def resolve_rest_references(app, doctree):
def copy_assets(app, exception):
assets = ('bootstrap.min.css', 'api-site.css',
'bootstrap.min.js', 'api-site.js',
'glyphicons-halflings-regular.ttf',
'glyphicons-halflings-regular.woff')
assets = ('api-site.css', 'api-site.js')
fonts = (
'glyphicons-halflings-regular.ttf',
'glyphicons-halflings-regular.woff'
)
if app.builder.name != 'html' or exception:
return
app.info('Copying assets: %s' % ', '.join(assets))
app.info('Copying fonts: %s' % ', '.join(fonts))
for asset in assets:
dest = os.path.join(app.builder.outdir, '_static', asset)
source = os.path.abspath(os.path.dirname(__file__))
copyfile(os.path.join(source, 'assets', asset), dest)
for font in fonts:
dest = os.path.join(app.builder.outdir, '_static/fonts', font)
source = os.path.abspath(os.path.dirname(__file__))
copyfile(os.path.join(source, 'assets', font), dest)
def add_assets(app):
app.add_stylesheet('bootstrap.min.css')
app.add_stylesheet('api-site.css')
app.add_javascript('bootstrap.min.js')
app.add_javascript('api-site.js')

View File

@ -11,46 +11,17 @@ tt.literal {
larger, we need them smaller */
blockquote { font-size: 1em; }
pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.428571429;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
tbody>tr:nth-child(odd)>td,
tbody>tr:nth-child(odd)>th {
background-color: #f9f9f9;
}
table>thead>tr>th, table>tbody>tr>th, table>tfoot>tr>th, table>thead>tr>td, table>tbody>tr>td, table>tfoot>tr>td {
padding: 8px;
line-height: 1.428571429;
vertical-align: top;
border-top: 1px solid #ddd;
}
td>p {
margin: 0 0 0.5em;
}
div.document {
width: 80% !important;
}
@media (max-width: 1200px) {
div.document {
width: 960px !important;
}
}
.operation-grp {
padding-top: 0.5em;
padding-bottom: 1em;
@ -119,6 +90,18 @@ a.operation-anchor {
background-color: #c9302c;
}
.btn-detail:hover, .btn-detail:focus,
.btn-expand-all:hover, .btn-expand-all:focus {
color: #fff;
background-color: #3b6c91;
border-color: #269abc;
}
.btn-detail,
.btn-expand-all {
background-color: #2A4E68;
}
span.path_parameter {
font-family: monospace;
padding: 2px 4px;
@ -145,3 +128,31 @@ p.url-subtitle {
color: #555;
font-weight: bold;
}
.docs-body .section h1 {
display: block;
}
div.docs-sidebar-toc > div > ul > li {
list-style-type: none;
font-size: 0.8em;
font-weight: bold;
}
div.docs-sidebar-toc > div > ul {
padding-left: 20px
}
div.docs-sidebar-toc > div > ul > li > ul > li {
list-style-type: disc;
font-weight: normal;
}
div.docs-top-contents {
display: none;
}
div.endpoint-container{
padding-left: 15px;
padding-top: 10px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,9 +17,16 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
import openstackdocstheme
html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = {
"sidebar_mode": "toc",
}
extensions = [
'os_api_ref',
'oslosphinx',
]
# The suffix of source filenames.

View File

@ -17,9 +17,16 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
import openstackdocstheme
html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = {
"sidebar_mode": "toc",
}
extensions = [
'os_api_ref',
'oslosphinx',
]
# The suffix of source filenames.

View File

@ -17,9 +17,16 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
import openstackdocstheme
html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = {
"sidebar_mode": "toc",
}
extensions = [
'os_api_ref',
'oslosphinx',
]
# The suffix of source filenames.

View File

@ -48,11 +48,11 @@ class TestMicroversions(base.TestCase):
"""Test that min / max mv css class attributes are set"""
content = self.soup.find_all(class_='rp_min_ver_2_17')
self.assertIn(
'<div class="row operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ">',
'<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ">',
str(content[0]))
content = self.soup.find_all(class_='rp_max_ver_2_19')
self.assertIn(
'<div class="row operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ">',
'<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ">',
str(content[0]))
def test_parameters_table(self):

View File

@ -6,3 +6,4 @@ pbr>=1.6
PyYAML>=3.1.0
docutils
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
openstackdocstheme>=1.4.0 # Apache-2.0