diff --git a/.gitignore b/.gitignore index 805ea28a8f0..29a1d85cb56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /_build /_exts +*.pyc diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 486727b665d..00000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "sphinx-php"] - path = _exts - url = http://github.com/fabpot/sphinx-php diff --git a/.travis.yml b/.travis.yml index 667ca86fa50..29682488140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ cache: - $HOME/.cache/pip - _build -install: pip install sphinx==1.1.3 +install: pip install sphinx~=1.3 git+https://github.com/fabpot/sphinx-php.git script: sphinx-build -nW -b html -d _build/doctrees . _build/html diff --git a/_exts b/_exts deleted file mode 160000 index 52f7bd2216c..00000000000 --- a/_exts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 52f7bd2216cc22ef52494f346c5643bb2a74513f diff --git a/_theme/_exts/symfonycom/__init__.py b/_theme/_exts/symfonycom/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/_theme/_exts/symfonycom/sphinx/__init__.py b/_theme/_exts/symfonycom/sphinx/__init__.py new file mode 100644 index 00000000000..1c08bcc11c8 --- /dev/null +++ b/_theme/_exts/symfonycom/sphinx/__init__.py @@ -0,0 +1,167 @@ +from sphinx.highlighting import lexers, PygmentsBridge +from pygments.style import Style +from pygments.formatters import HtmlFormatter +from pygments.token import Keyword, Name, Comment, String, Error, \ + Number, Operator, Generic, Whitespace, Punctuation, Other, Literal + +from sphinx.writers.html import HTMLTranslator +from docutils import nodes +from sphinx.locale import admonitionlabels, lazy_gettext + +customadmonitionlabels = admonitionlabels +l_ = lazy_gettext +customadmonitionlabels['best-practice'] = l_('Best Practice') + +def _getType(path): + return path[:path.find('/')] + +def _isIndex(path): + return 'index' in path + +class SensioHTMLTranslator(HTMLTranslator): + def __init__(self, builder, *args, **kwds): + HTMLTranslator.__init__(self, builder, *args, **kwds) + builder.templates.environment.filters['get_type'] = _getType + builder.templates.environment.tests['index'] = _isIndex + self.highlightlinenothreshold = 0 + + def visit_literal(self, node): + self.body.append(self.starttag(node, 'tt', '', CLASS='docutils literal')) + self.body.append('') + + def depart_literal(self, node): + self.body.append('') + self.body.append('') + + def visit_admonition(self, node, name=''): + self.body.append(self.starttag(node, 'div', CLASS=('admonition-wrapper'))) + self.body.append('
') + self.body.append('
') + if name and name != 'seealso': + node.insert(0, nodes.title(name, customadmonitionlabels[name])) + self.set_first_last(node) + + def depart_admonition(self, node=None): + self.body.append('
\n') + + def visit_sidebar(self, node): + self.body.append(self.starttag(node, 'div', CLASS=('admonition-wrapper'))) + self.body.append('') + self.body.append('
') + self.set_first_last(node) + self.in_sidebar = 1 + + def depart_sidebar(self, node): + self.body.append('
\n') + self.in_sidebar = None + + # overriden to add a new highlight div around each block + def visit_literal_block(self, node): + if node.rawsource != node.astext(): + # most probably a parsed-literal block -- don't highlight + return BaseTranslator.visit_literal_block(self, node) + lang = self.highlightlang + linenos = node.rawsource.count('\n') >= \ + self.highlightlinenothreshold - 1 + highlight_args = node.get('highlight_args', {}) + if node.has_key('language'): + # code-block directives + lang = node['language'] + highlight_args['force'] = True + if node.has_key('linenos'): + linenos = node['linenos'] + def warner(msg): + self.builder.warn(msg, (self.builder.current_docname, node.line)) + highlighted = self.highlighter.highlight_block( + node.rawsource, lang, warn=warner, linenos=linenos, + **highlight_args) + starttag = self.starttag(node, 'div', suffix='', + CLASS='highlight-%s' % lang) + self.body.append('
' + starttag + highlighted + '
\n') + raise nodes.SkipNode + +class SensioStyle(Style): + background_color = "#000000" + default_style = "" + + styles = { + # No corresponding class for the following: + #Text: "", # class: '' + Whitespace: "underline #f8f8f8", # class: 'w' + Error: "#a40000 border:#ef2929", # class: 'err' + Other: "#ffffff", # class 'x' + + Comment: "italic #B729D9", # class: 'c' + Comment.Single: "italic #B729D9", # class: 'c1' + Comment.Multiline: "italic #B729D9", # class: 'cm' + Comment.Preproc: "noitalic #aaa", # class: 'cp' + + Keyword: "#FF8400", # class: 'k' + Keyword.Constant: "#FF8400", # class: 'kc' + Keyword.Declaration: "#FF8400", # class: 'kd' + Keyword.Namespace: "#FF8400", # class: 'kn' + Keyword.Pseudo: "#FF8400", # class: 'kp' + Keyword.Reserved: "#FF8400", # class: 'kr' + Keyword.Type: "#FF8400", # class: 'kt' + + Operator: "#E0882F", # class: 'o' + Operator.Word: "#E0882F", # class: 'ow' - like keywords + + Punctuation: "#999999", # class: 'p' + + # because special names such as Name.Class, Name.Function, etc. + # are not recognized as such later in the parsing, we choose them + # to look the same as ordinary variables. + Name: "#ffffff", # class: 'n' + Name.Attribute: "#ffffff", # class: 'na' - to be revised + Name.Builtin: "#ffffff", # class: 'nb' + Name.Builtin.Pseudo: "#3465a4", # class: 'bp' + Name.Class: "#ffffff", # class: 'nc' - to be revised + Name.Constant: "#ffffff", # class: 'no' - to be revised + Name.Decorator: "#888", # class: 'nd' - to be revised + Name.Entity: "#ce5c00", # class: 'ni' + Name.Exception: "#cc0000", # class: 'ne' + Name.Function: "#ffffff", # class: 'nf' + Name.Property: "#ffffff", # class: 'py' + Name.Label: "#f57900", # class: 'nl' + Name.Namespace: "#ffffff", # class: 'nn' - to be revised + Name.Other: "#ffffff", # class: 'nx' + Name.Tag: "#cccccc", # class: 'nt' - like a keyword + Name.Variable: "#ffffff", # class: 'nv' - to be revised + Name.Variable.Class: "#ffffff", # class: 'vc' - to be revised + Name.Variable.Global: "#ffffff", # class: 'vg' - to be revised + Name.Variable.Instance: "#ffffff", # class: 'vi' - to be revised + + Number: "#1299DA", # class: 'm' + + Literal: "#ffffff", # class: 'l' + Literal.Date: "#ffffff", # class: 'ld' + + String: "#56DB3A", # class: 's' + String.Backtick: "#56DB3A", # class: 'sb' + String.Char: "#56DB3A", # class: 'sc' + String.Doc: "italic #B729D9", # class: 'sd' - like a comment + String.Double: "#56DB3A", # class: 's2' + String.Escape: "#56DB3A", # class: 'se' + String.Heredoc: "#56DB3A", # class: 'sh' + String.Interpol: "#56DB3A", # class: 'si' + String.Other: "#56DB3A", # class: 'sx' + String.Regex: "#56DB3A", # class: 'sr' + String.Single: "#56DB3A", # class: 's1' + String.Symbol: "#56DB3A", # class: 'ss' + + Generic: "#ffffff", # class: 'g' + Generic.Deleted: "#a40000", # class: 'gd' + Generic.Emph: "italic #ffffff", # class: 'ge' + Generic.Error: "#ef2929", # class: 'gr' + Generic.Heading: "#000080", # class: 'gh' + Generic.Inserted: "#00A000", # class: 'gi' + Generic.Output: "#888", # class: 'go' + Generic.Prompt: "#745334", # class: 'gp' + Generic.Strong: "bold #ffffff", # class: 'gs' + Generic.Subheading: "bold #800080", # class: 'gu' + Generic.Traceback: "bold #a40000", # class: 'gt' + } + +def setup(app): + app.set_translator('html', SensioHTMLTranslator) diff --git a/_theme/_templates/globaltoc.html b/_theme/_templates/globaltoc.html new file mode 100644 index 00000000000..0dfcc246dd7 --- /dev/null +++ b/_theme/_templates/globaltoc.html @@ -0,0 +1,20 @@ + diff --git a/_theme/_templates/layout.html b/_theme/_templates/layout.html new file mode 100644 index 00000000000..01bce31b749 --- /dev/null +++ b/_theme/_templates/layout.html @@ -0,0 +1,98 @@ +{% extends '!layout.html' %} + +{% set css_files = ['http://symfony.com/css/compiled/v5/all.css?v=4'] %} +{# make sure the Sphinx stylesheet isn't loaded #} +{% set style = '' %} +{% set isIndex = pagename is index %} + +{% block extrahead %} +{# add JS to support tabs #} + + +{# pygment's styles are still loaded, undo some unwanted styles #} + +{% endblock %} + +{% block header %} +{# ugly way, now we have 2 body tags, but styles rely on these classes #} + +{% endblock %} + +{% block content %} +
+
+ {%- if render_sidebar %} + + {%- endif %} + +
+ + +

{{ title }}

+ +
+ {% block body %}{% endblock %} +
+ + {% if prev and next %} + + {% endif %} + +
+

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

+
+
+
+
+{% endblock %} + +{# relbar1 is at the top and should not render the quick navigation #} +{% block relbar1 %}{% endblock %} +{% block relbar2 %}{% endblock %} + +{# remove "generated by sphinx" footer #} +{% block footer %}{% endblock %} diff --git a/_theme/_templates/localtoc.html b/_theme/_templates/localtoc.html new file mode 100644 index 00000000000..0ffea6e1ecd --- /dev/null +++ b/_theme/_templates/localtoc.html @@ -0,0 +1,6 @@ +
+

{{ _('Table Of Contents') }}

+
+ {{ toc }} +
+
diff --git a/conf.py b/conf.py index ab4e823e384..e7c6b9d1800 100644 --- a/conf.py +++ b/conf.py @@ -16,9 +16,7 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -sys.path.append(os.path.abspath('_exts')) +sys.path.append(os.path.abspath('_theme/_exts')) # adding PhpLexer from sphinx.highlighting import lexers @@ -34,11 +32,14 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', - 'sensio.sphinx.refinclude', 'sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode', 'sensio.sphinx.bestpractice'] +extensions = [ + 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', + 'sensio.sphinx.refinclude', 'sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode', 'sensio.sphinx.bestpractice', 'sensio.sphinx.codeblock', + 'symfonycom.sphinx' +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ['_theme/_templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -74,7 +75,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -# exclude_patterns = ['_build', 'bundles'] +exclude_patterns = ['_theme'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None @@ -126,7 +127,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = 'classic' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the