Skip to content

Commit d5ca747

Browse files
pdavidelibremente
authored andcommitted
Clean up conf.py and add reqs (#24)
- Docs Italia compatibility
1 parent 09dcde9 commit d5ca747

3 files changed

Lines changed: 20 additions & 555 deletions

File tree

_docs/en/conf.py

Lines changed: 9 additions & 277 deletions
Original file line numberDiff line numberDiff line change
@@ -1,283 +1,15 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
# -- PROJECT Variables ----------------------------------------------------
5-
settings_project_name = "publiccode.yml"
6-
settings_copyright_copyleft = 'Public Domain'
7-
settings_editor_name = 'Team Digitale'
8-
settings_doc_version = 'version 0.1'
9-
settings_doc_release = '0.1'
10-
settings_basename = 'publiccode.yml'
11-
settings_file_name = 'publiccode.yml'
12-
13-
# -- No need to change below here
14-
15-
import sys, os
16-
docs_italia_theme = __import__("docs-italia-theme")
17-
from recommonmark.transform import AutoStructify
18-
from recommonmark.parser import CommonMarkParser
19-
20-
# -- RTD configuration ------------------------------------------------
21-
22-
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
23-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
24-
25-
# This is used for linking and such so we link to the thing we're building
26-
rtd_version = os.environ.get('READTHEDOCS_VERSION', 'latest')
27-
if rtd_version not in ['stable', 'latest']:
28-
rtd_version = 'stable'
29-
30-
rtd_project = os.environ.get('READTHEDOCS_PROJECT', '')
31-
32-
# If extensions (or modules to document with autodoc) are in another directory,
33-
# add these directories to sys.path here. If the directory is relative to the
34-
# documentation root, use os.path.abspath to make it absolute, like shown here.
35-
#sys.path.insert(0, os.path.abspath('.'))
36-
37-
# -- General configuration -----------------------------------------------------
38-
39-
# If your documentation needs a minimal Sphinx version, state it here.
40-
#needs_sphinx = '1.0'
41-
42-
# Add any Sphinx extension module names here, as strings. They can be
43-
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
44-
extensions = [
45-
'sphinx.ext.autodoc',
46-
'sphinx.ext.doctest',
47-
'sphinx.ext.intersphinx',
48-
'sphinx.ext.todo',
49-
'sphinx.ext.coverage',
50-
'sphinx.ext.ifconfig',
51-
'docs-italia-theme',
52-
]
53-
54-
# Add any paths that contain templates here, relative to this directory.
55-
templates_path = ['_templates']
56-
57-
# The suffix of source filenames.
58-
source_parsers = {
59-
'.md': CommonMarkParser,
60-
}
61-
62-
source_suffix = ['.rst', '.md']
63-
64-
# The encoding of source files.
65-
#source_encoding = 'utf-8-sig'
66-
source_encoding = 'utf-8'
67-
684
# The master toctree document.
695
master_doc = 'index'
706

71-
# General information about the project.
72-
project = settings_project_name
73-
copyright = settings_copyright_copyleft
74-
75-
# URL of Discourse instance used by sphinxcontrib.discourse extension
76-
# discourse_url = settings_discourse_url
77-
78-
# The version info for the project you're documenting, acts as replacement for
79-
# |version| and |release|, also used in various other places throughout the
80-
# built documents.
81-
#
82-
# The short X.Y version.
83-
version = settings_doc_version
84-
# The full version, including alpha/beta/rc tags.
85-
release = settings_doc_release
86-
87-
# The language for content autogenerated by Sphinx. Refer to documentation
88-
# for a list of supported languages.
89-
language = 'it'
90-
91-
# There are two options for replacing |today|: either, you set today to some
92-
# non-false value, then it is used:
93-
#today = ''
94-
# Else, today_fmt is used as the format for a strftime call.
95-
#today_fmt = '%B %d, %Y'
96-
97-
# List of patterns, relative to source directory, that match files and
98-
# directories to ignore when looking for source files.
99-
exclude_patterns = ['.DS_Store', 'README', 'README.md', '.venv*']
100-
101-
# The name of the Pygments (syntax highlighting) style to use.
102-
pygments_style = 'sphinx'
103-
104-
# -- AutoStructify --------------------------------------------------------
105-
def setup(app):
106-
app.add_config_value('recommonmark_config', {
107-
'auto_toc_tree_section': 'Contents',
108-
'enable_eval_rst': True,
109-
'enable_auto_doc_ref': True
110-
}, True)
111-
app.add_transform(AutoStructify)
112-
113-
114-
# -- Options for HTML output ----------------------------------------------
115-
html_theme = 'docs-italia-theme'
116-
117-
html_theme_path = [docs_italia_theme.get_html_theme_path()]
118-
119-
# Theme options are theme-specific and customize the look and feel of a theme
120-
# further. For a list of options available for each theme, see the
121-
# documentation.
122-
html_theme_options = {
123-
# This option can be used with docs-italia-theme to customise how the versions "badge" is shown:
124-
# 'False': default (alabaster) badge | 'True': custom (italia) badge
125-
'custom_versions_badge': 'True',
126-
}
127-
# -- ReadTheDoc requirements and local template generation---------------------
128-
129-
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
130-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
131-
132-
if not on_rtd: # only import and set the theme if we're building docs locally
133-
html_theme = 'docs-italia-theme'
134-
#html_theme_path = ["themes", ]
135-
else:
136-
# Override default css to get a larger width for ReadTheDoc build
137-
html_context = {
138-
'css_files': [
139-
'_static/css/theme.css',
140-
'_static/css/badge_only.css',
141-
],
142-
}
143-
144-
145-
# The name for this set of Sphinx documents. If None, it defaults to
146-
# "<project> v<release> documentation".
147-
#html_title = settings_project_name
148-
149-
# A shorter title for the navigation bar. Default is the same as html_title.
150-
#html_short_title = None
151-
152-
# The name of an image file (relative to this directory) to place at the top
153-
# of the sidebar.
154-
# html_logo = "images/logo.png"
155-
156-
# The name of an image file (within the static path) to use as favicon of the
157-
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
158-
# pixels large.
159-
#html_favicon = None
160-
161-
# Add any paths that contain custom static files (such as style sheets) here,
162-
# relative to this directory. They are copied after the builtin static files,
163-
# so a file named "default.css" will overwrite the builtin "default.css".
164-
html_static_path = ['_static']
165-
166-
# Add any extra paths that contain custom files (such as robots.txt or
167-
# .htaccess) here, relative to this directory. These files are copied
168-
# directly to the root of the documentation.
169-
#html_extra_path = []
170-
171-
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
172-
# using the given strftime format.
173-
html_last_updated_fmt = '%d/%m/%Y'
174-
175-
# If true, SmartyPants will be used to convert quotes and dashes to
176-
# typographically correct entities.
177-
#html_use_smartypants = True
178-
179-
# Custom sidebar templates, maps document names to template names.
180-
#html_sidebars = {}
181-
182-
# Additional templates that should be rendered to pages, maps page names to
183-
# template names.
184-
#html_additional_pages = {}
185-
186-
# If false, no module index is generated.
187-
#html_domain_indices = True
188-
189-
# If false, no index is generated.
190-
#html_use_index = True
191-
192-
# If true, the index is split into individual pages for each letter.
193-
#html_split_index = False
194-
195-
# If true, links to the reST sources are added to the pages.
196-
#html_show_sourcelink = True
197-
198-
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
199-
#html_show_sphinx = True
200-
201-
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
202-
# html_show_copyright = True
203-
204-
# If true, an OpenSearch description file will be output, and all pages will
205-
# contain a <link> tag referring to it. The value of this option must be the
206-
# base URL from which the finished HTML is served.
207-
#html_use_opensearch = ''
208-
209-
# This is the file name suffix for HTML files (e.g. ".xhtml").
210-
#html_file_suffix = None
211-
212-
# Output file base name for HTML help builder.
213-
htmlhelp_basename = settings_basename + 'doc'
214-
215-
216-
# -- Options for LaTeX output ---------------------------------------------
217-
218-
latex_elements = {
219-
# The paper size ('letterpaper' or 'a4paper').
220-
#'papersize': 'a4paper',
221-
222-
# The font size ('10pt', '11pt' or '12pt').
223-
#'pointsize': '10pt',
224-
225-
# Additional stuff for the LaTeX preamble.
226-
#'preamble': '',
227-
}
228-
229-
# Grouping the document tree into LaTeX files. List of tuples
230-
# (source start file, target name, title,
231-
# author, documentclass [howto, manual, or own class]).
232-
latex_documents = [
233-
('index', settings_file_name + '.tex', settings_project_name,
234-
settings_copyright_copyleft, 'manual'),
235-
]
236-
237-
# The name of an image file (relative to this directory) to place at the top of
238-
# the title page.
239-
#latex_logo = "images/..."
240-
241-
# For "manual" documents, if this is true, then toplevel headings are parts,
242-
# not chapters.
243-
#latex_use_parts = False
244-
245-
# If true, show page references after internal links.
246-
#latex_show_pagerefs = False
247-
248-
# If true, show URL addresses after external links.
249-
#latex_show_urls = False
250-
251-
# Documents to append as an appendix to all manuals.
252-
#latex_appendices = []
253-
254-
# If false, no module index is generated.
255-
#latex_domain_indices = True
256-
257-
258-
# -- Options for manual page output ---------------------------------------
259-
260-
# One entry per manual page. List of tuples
261-
# (source start file, name, description, authors, manual section).
262-
man_pages = [
263-
('index', settings_file_name, settings_project_name,
264-
[settings_editor_name], 1)
265-
]
266-
267-
# If true, show URL addresses after external links.
268-
#man_show_urls = False
269-
270-
271-
# -- Options for Texinfo output -------------------------------------------
272-
273-
# Grouping the document tree into Texinfo files. List of tuples
274-
# (source start file, target name, title, author,
275-
# dir menu entry, description, category)
276-
texinfo_documents = [
277-
('index', settings_file_name, settings_project_name,
278-
settings_copyright_copyleft, settings_project_name, settings_project_name,
279-
'Miscellaneous'),
280-
]
281-
282-
numfig = True
283-
7+
# Monkey patch to fix recommonmark 0.4 doc reference issues.
8+
# See https://github.com/rtfd/recommonmark/issues/93#issuecomment-441798805
9+
from recommonmark.states import DummyStateMachine
10+
orig_run_role = DummyStateMachine.run_role
11+
def run_role(self, name, options=None, content=None):
12+
if name == 'doc':
13+
name = 'any'
14+
return orig_run_role(self, name, options, content)
15+
DummyStateMachine.run_role = run_role

0 commit comments

Comments
 (0)