Skip to content

Commit a991ea1

Browse files
committed
Merge branch '2.8'
* 2.8: Reset some more pygments styles Use pip instead of submodules Use numbered code block Add demo warning Move Sphinx files to _theme Update config Use a more recent version of Sphinx Temporary disable codeblock Use symfony.com theme on Platform.sh builds Update page_creation.rst [#5593] Very little rewording and improving config Updated the profiler matchers article don't override existing variables [Cookbook][Session] fix default expiry field name Fix code
2 parents b25b9e5 + 7f05db4 commit a991ea1

File tree

15 files changed

+372
-56
lines changed

15 files changed

+372
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/_build
22
/_exts
3+
*.pyc

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cache:
99
- $HOME/.cache/pip
1010
- _build
1111

12-
install: pip install sphinx==1.1.3
12+
install: pip install sphinx~=1.3 git+https://github.com/fabpot/sphinx-php.git
1313

1414
script: sphinx-build -nW -b html -d _build/doctrees . _build/html
1515

_exts

Lines changed: 0 additions & 1 deletion
This file was deleted.

_theme/_exts/symfonycom/__init__.py

Whitespace-only changes.
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
from sphinx.highlighting import lexers, PygmentsBridge
2+
from pygments.style import Style
3+
from pygments.formatters import HtmlFormatter
4+
from pygments.token import Keyword, Name, Comment, String, Error, \
5+
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
6+
7+
from sphinx.writers.html import HTMLTranslator
8+
from docutils import nodes
9+
from sphinx.locale import admonitionlabels, lazy_gettext
10+
11+
customadmonitionlabels = admonitionlabels
12+
l_ = lazy_gettext
13+
customadmonitionlabels['best-practice'] = l_('Best Practice')
14+
15+
def _getType(path):
16+
return path[:path.find('/')]
17+
18+
def _isIndex(path):
19+
return 'index' in path
20+
21+
class SensioHTMLTranslator(HTMLTranslator):
22+
def __init__(self, builder, *args, **kwds):
23+
HTMLTranslator.__init__(self, builder, *args, **kwds)
24+
builder.templates.environment.filters['get_type'] = _getType
25+
builder.templates.environment.tests['index'] = _isIndex
26+
self.highlightlinenothreshold = 0
27+
28+
def visit_literal(self, node):
29+
self.body.append(self.starttag(node, 'tt', '', CLASS='docutils literal'))
30+
self.body.append('<code>')
31+
32+
def depart_literal(self, node):
33+
self.body.append('</code>')
34+
self.body.append('</tt>')
35+
36+
def visit_admonition(self, node, name=''):
37+
self.body.append(self.starttag(node, 'div', CLASS=('admonition-wrapper')))
38+
self.body.append('<div class="' + name + '"></div>')
39+
self.body.append('<div class="admonition admonition-' + name + '">')
40+
if name and name != 'seealso':
41+
node.insert(0, nodes.title(name, customadmonitionlabels[name]))
42+
self.set_first_last(node)
43+
44+
def depart_admonition(self, node=None):
45+
self.body.append('</div></div>\n')
46+
47+
def visit_sidebar(self, node):
48+
self.body.append(self.starttag(node, 'div', CLASS=('admonition-wrapper')))
49+
self.body.append('<div class="sidebar"></div>')
50+
self.body.append('<div class="admonition admonition-sidebar">')
51+
self.set_first_last(node)
52+
self.in_sidebar = 1
53+
54+
def depart_sidebar(self, node):
55+
self.body.append('</div></div>\n')
56+
self.in_sidebar = None
57+
58+
# overriden to add a new highlight div around each block
59+
def visit_literal_block(self, node):
60+
if node.rawsource != node.astext():
61+
# most probably a parsed-literal block -- don't highlight
62+
return BaseTranslator.visit_literal_block(self, node)
63+
lang = self.highlightlang
64+
linenos = node.rawsource.count('\n') >= \
65+
self.highlightlinenothreshold - 1
66+
highlight_args = node.get('highlight_args', {})
67+
if node.has_key('language'):
68+
# code-block directives
69+
lang = node['language']
70+
highlight_args['force'] = True
71+
if node.has_key('linenos'):
72+
linenos = node['linenos']
73+
def warner(msg):
74+
self.builder.warn(msg, (self.builder.current_docname, node.line))
75+
highlighted = self.highlighter.highlight_block(
76+
node.rawsource, lang, warn=warner, linenos=linenos,
77+
**highlight_args)
78+
starttag = self.starttag(node, 'div', suffix='',
79+
CLASS='highlight-%s' % lang)
80+
self.body.append('<div class="literal-block">' + starttag + highlighted + '</div></div>\n')
81+
raise nodes.SkipNode
82+
83+
class SensioStyle(Style):
84+
background_color = "#000000"
85+
default_style = ""
86+
87+
styles = {
88+
# No corresponding class for the following:
89+
#Text: "", # class: ''
90+
Whitespace: "underline #f8f8f8", # class: 'w'
91+
Error: "#a40000 border:#ef2929", # class: 'err'
92+
Other: "#ffffff", # class 'x'
93+
94+
Comment: "italic #B729D9", # class: 'c'
95+
Comment.Single: "italic #B729D9", # class: 'c1'
96+
Comment.Multiline: "italic #B729D9", # class: 'cm'
97+
Comment.Preproc: "noitalic #aaa", # class: 'cp'
98+
99+
Keyword: "#FF8400", # class: 'k'
100+
Keyword.Constant: "#FF8400", # class: 'kc'
101+
Keyword.Declaration: "#FF8400", # class: 'kd'
102+
Keyword.Namespace: "#FF8400", # class: 'kn'
103+
Keyword.Pseudo: "#FF8400", # class: 'kp'
104+
Keyword.Reserved: "#FF8400", # class: 'kr'
105+
Keyword.Type: "#FF8400", # class: 'kt'
106+
107+
Operator: "#E0882F", # class: 'o'
108+
Operator.Word: "#E0882F", # class: 'ow' - like keywords
109+
110+
Punctuation: "#999999", # class: 'p'
111+
112+
# because special names such as Name.Class, Name.Function, etc.
113+
# are not recognized as such later in the parsing, we choose them
114+
# to look the same as ordinary variables.
115+
Name: "#ffffff", # class: 'n'
116+
Name.Attribute: "#ffffff", # class: 'na' - to be revised
117+
Name.Builtin: "#ffffff", # class: 'nb'
118+
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
119+
Name.Class: "#ffffff", # class: 'nc' - to be revised
120+
Name.Constant: "#ffffff", # class: 'no' - to be revised
121+
Name.Decorator: "#888", # class: 'nd' - to be revised
122+
Name.Entity: "#ce5c00", # class: 'ni'
123+
Name.Exception: "#cc0000", # class: 'ne'
124+
Name.Function: "#ffffff", # class: 'nf'
125+
Name.Property: "#ffffff", # class: 'py'
126+
Name.Label: "#f57900", # class: 'nl'
127+
Name.Namespace: "#ffffff", # class: 'nn' - to be revised
128+
Name.Other: "#ffffff", # class: 'nx'
129+
Name.Tag: "#cccccc", # class: 'nt' - like a keyword
130+
Name.Variable: "#ffffff", # class: 'nv' - to be revised
131+
Name.Variable.Class: "#ffffff", # class: 'vc' - to be revised
132+
Name.Variable.Global: "#ffffff", # class: 'vg' - to be revised
133+
Name.Variable.Instance: "#ffffff", # class: 'vi' - to be revised
134+
135+
Number: "#1299DA", # class: 'm'
136+
137+
Literal: "#ffffff", # class: 'l'
138+
Literal.Date: "#ffffff", # class: 'ld'
139+
140+
String: "#56DB3A", # class: 's'
141+
String.Backtick: "#56DB3A", # class: 'sb'
142+
String.Char: "#56DB3A", # class: 'sc'
143+
String.Doc: "italic #B729D9", # class: 'sd' - like a comment
144+
String.Double: "#56DB3A", # class: 's2'
145+
String.Escape: "#56DB3A", # class: 'se'
146+
String.Heredoc: "#56DB3A", # class: 'sh'
147+
String.Interpol: "#56DB3A", # class: 'si'
148+
String.Other: "#56DB3A", # class: 'sx'
149+
String.Regex: "#56DB3A", # class: 'sr'
150+
String.Single: "#56DB3A", # class: 's1'
151+
String.Symbol: "#56DB3A", # class: 'ss'
152+
153+
Generic: "#ffffff", # class: 'g'
154+
Generic.Deleted: "#a40000", # class: 'gd'
155+
Generic.Emph: "italic #ffffff", # class: 'ge'
156+
Generic.Error: "#ef2929", # class: 'gr'
157+
Generic.Heading: "#000080", # class: 'gh'
158+
Generic.Inserted: "#00A000", # class: 'gi'
159+
Generic.Output: "#888", # class: 'go'
160+
Generic.Prompt: "#745334", # class: 'gp'
161+
Generic.Strong: "bold #ffffff", # class: 'gs'
162+
Generic.Subheading: "bold #800080", # class: 'gu'
163+
Generic.Traceback: "bold #a40000", # class: 'gt'
164+
}
165+
166+
def setup(app):
167+
app.set_translator('html', SensioHTMLTranslator)

_theme/_templates/globaltoc.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class=submenu>
2+
{% set menu = [
3+
('The Book', 'book/index'),
4+
('The Cookbook', 'cookbook/index'),
5+
('The Components', 'components/index'),
6+
('The Best Practices', 'best_practices/index'),
7+
('The Quick Tour', 'quick_tour/index'),
8+
('Reference', 'reference/index'),
9+
('Index', 'genindex'),
10+
('Contributing', 'contributing/index')
11+
] %}
12+
13+
<ul class="list_submenu list-unstyled">
14+
{% for name, doc in menu %}
15+
<li {% if loop.first %}class="first"{% endif %}>
16+
<a href="{{ pathto(doc) }}">{{ name }}</a>
17+
</li>
18+
{% endfor %}
19+
</ul>
20+
</div>

_theme/_templates/layout.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{% extends '!layout.html' %}
2+
3+
{% set css_files = ['http://symfony.com/css/compiled/v5/all.css?v=4'] %}
4+
{# make sure the Sphinx stylesheet isn't loaded #}
5+
{% set style = '' %}
6+
{% set isIndex = pagename is index %}
7+
8+
{% block extrahead %}
9+
{# add JS to support tabs #}
10+
<script src="http://symfony.com/js/v5/all.js?v=4"></script>
11+
12+
{# pygment's styles are still loaded, undo some unwanted styles #}
13+
<style>
14+
.highlight .k, .highlight .gh, .highlight .gp,
15+
.highlight .gu, .highlight .kc, .highlight .kd,
16+
.highlight .kn, .highlight .kr, .highlight .nc,
17+
.highlight .nd, .highlight .ni, .highlight .nl,
18+
.highlight .nn, .highlight .nt, .highlight .ow,
19+
.highlight .se { font-weight: normal; }
20+
21+
.highlight .c, .highlight .cm, .highlight .c1,
22+
.highlight .sd, .highlight .si { font-style: normal; }
23+
24+
.doc { background: none; }
25+
#demo-warning {
26+
border: 3px dashed #c00;
27+
padding: 10px;
28+
margin-bottom: 30px;
29+
}
30+
#demo-warning h4 { font-size: 1.7em;font-weight: bold; }
31+
#demo-warning p { margin-bottom: 0; }
32+
</style>
33+
{% endblock %}
34+
35+
{% block header %}
36+
{# ugly way, now we have 2 body tags, but styles rely on these classes #}
37+
<body class="{{ pagename|get_type }} {% if isIndex %}doc_index{% else %}doc_article{% endif %} doc">
38+
{% endblock %}
39+
40+
{% block content %}
41+
<div class="container"><div id="page-content">
42+
<div class="row">
43+
{%- if render_sidebar %}
44+
<div id="sidebar" class="col-sm-3">
45+
<div id="sidebar-content">
46+
<div id="demo-warning">
47+
<h4>This is a demo</h4>
48+
<p>This is a demo provided by platform.sh.<br>
49+
<a href="http://symfony.com/doc/current/{{ pagename }}">Visit on symfony.com</a>.</p>
50+
</div>
51+
52+
{%- include "globaltoc.html" %}
53+
54+
{% if not isIndex %}
55+
{%- include "localtoc.html" %}
56+
{% endif %}
57+
</div>
58+
</div>
59+
{%- endif %}
60+
61+
<div id="main" class="col-sm-9">
62+
<ol class=breadcrumb>
63+
<li><a href="#">Home</a></li>
64+
<li><a href="#">Documentation</a></li>
65+
{% for parent in parents %}
66+
<li><a href="{{ parent.link|e }}">{{ parent.title }}</a></li>
67+
{% endfor %}
68+
<li class=active>{{ title }}</li>
69+
</ol>
70+
71+
<h1 class="content_title">{{ title }}</h1>
72+
73+
<div class=page>
74+
{% block body %}{% endblock %}
75+
</div>
76+
77+
{% if prev and next %}
78+
<div class=navigation>
79+
<a href="{{ prev.link|e }}">« {{ prev.title|striptags|e }}</a>
80+
<span class=separator>|</span>
81+
<a href="{{ next.link|e }}">{{ next.title|striptags|e }} »</a>
82+
</div>
83+
{% endif %}
84+
85+
<div id="license">
86+
<p>This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">License</a>.</p>
87+
</div>
88+
</div>
89+
</div>
90+
</div>
91+
{% endblock %}
92+
93+
{# relbar1 is at the top and should not render the quick navigation #}
94+
{% block relbar1 %}{% endblock %}
95+
{% block relbar2 %}{% endblock %}
96+
97+
{# remove "generated by sphinx" footer #}
98+
{% block footer %}{% endblock %}

_theme/_templates/localtoc.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="toc">
2+
<h4>{{ _('Table Of Contents') }}</h4>
3+
<div class=toc-content>
4+
{{ toc }}
5+
</div>
6+
</div>

book/page_creation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Just add a second method to ``LuckyController``::
104104
// src/AppBundle/Controller/LuckyController.php
105105
// ...
106106

107-
class LuckyController
107+
class LuckyController extends Controller
108108
{
109109
// ...
110110

@@ -137,7 +137,7 @@ You can even shorten this with the handy :class:`Symfony\\Component\\HttpFoundat
137137
// --> don't forget this new use statement
138138
use Symfony\Component\HttpFoundation\JsonResponse;
139139

140-
class LuckyController
140+
class LuckyController extends Controller
141141
{
142142
// ...
143143

@@ -170,7 +170,7 @@ at the end:
170170
// src/AppBundle/Controller/LuckyController.php
171171
// ...
172172
173-
class LuckyController
173+
class LuckyController extends Controller
174174
{
175175
/**
176176
* @Route("/lucky/number/{count}")
@@ -224,7 +224,7 @@ The best part is that you can access this value and use it in your controller::
224224
// src/AppBundle/Controller/LuckyController.php
225225
// ...
226226

227-
class LuckyController
227+
class LuckyController extends Controller
228228
{
229229

230230
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy