conf.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. #=============================================================================
  2. # Copyright (c) 2017 Paul Fultz II
  3. # conf.py
  4. # Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #==============================================================================
  7. # -*- coding: utf-8 -*-
  8. #
  9. # Boost.HigherOrderFunctions documentation build configuration file, created by
  10. # sphinx-quickstart on Thu Jun 2 00:33:55 2016.
  11. #
  12. # This file is execfile()d with the current directory set to its
  13. # containing dir.
  14. #
  15. # Note that not all possible configuration values are present in this
  16. # autogenerated file.
  17. #
  18. # All configuration values have a default; values that are commented out
  19. # serve to show the default.
  20. # If extensions (or modules to document with autodoc) are in another directory,
  21. # add these directories to sys.path here. If the directory is relative to the
  22. # documentation root, use os.path.abspath to make it absolute, like shown here.
  23. #
  24. import os
  25. from recommonmark.parser import CommonMarkParser
  26. from recommonmark.transform import AutoStructify
  27. import sphinx_boost
  28. # -- General configuration ------------------------------------------------
  29. # If your documentation needs a minimal Sphinx version, state it here.
  30. #
  31. # needs_sphinx = '1.0'
  32. # Add any Sphinx extension module names here, as strings. They can be
  33. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  34. # ones.
  35. extensions = [
  36. # 'sphinx.ext.autodoc',
  37. # 'sphinx.ext.githubpages',
  38. 'sphinx.ext.autosectionlabel',
  39. ]
  40. # Add any paths that contain templates here, relative to this directory.
  41. templates_path = ['_templates']
  42. source_parsers = {
  43. '.md': CommonMarkParser,
  44. '.hpp': CommonMarkParser
  45. }
  46. # The suffix(es) of source filenames.
  47. # You can specify multiple suffix as a list of string:
  48. #
  49. source_suffix = ['.rst', '.md', '.hpp']
  50. # source_suffix = '.rst'
  51. # The encoding of source files.
  52. #
  53. # source_encoding = 'utf-8-sig'
  54. # The master toctree document.
  55. master_doc = 'doc/index'
  56. # General information about the project.
  57. project = u'Boost.HigherOrderFunctions'
  58. copyright = u'2016, Paul Fultz II'
  59. author = u'Paul Fultz II'
  60. # The version info for the project you're documenting, acts as replacement for
  61. # |version| and |release|, also used in various other places throughout the
  62. # built documents.
  63. #
  64. def parse_version():
  65. lines = open('../include/boost/hof/version.hpp').readlines()
  66. defines = ['BOOST_HOF_VERSION_MAJOR', 'BOOST_HOF_VERSION_MINOR', 'BOOST_HOF_VERSION_PATCH']
  67. versions = ['0','0','0']
  68. for line in lines:
  69. for di, define in enumerate(defines):
  70. needle = '#define ' + define
  71. i = line.find(needle)
  72. if i >= 0:
  73. versions[di] = line[i+len(needle):].strip()
  74. final_version = versions[0] + '.' + versions[1]
  75. if versions[2] != '0': final_version = final_version + '.' + versions[2]
  76. return final_version
  77. # The short X.Y version.
  78. version = parse_version()
  79. # The full version, including alpha/beta/rc tags.
  80. release = version
  81. # The language for content autogenerated by Sphinx. Refer to documentation
  82. # for a list of supported languages.
  83. #
  84. # This is also used if you do content translation via gettext catalogs.
  85. # Usually you set "language" from the command line for these cases.
  86. language = None
  87. # There are two options for replacing |today|: either, you set today to some
  88. # non-false value, then it is used:
  89. #
  90. # today = ''
  91. #
  92. # Else, today_fmt is used as the format for a strftime call.
  93. #
  94. # today_fmt = '%B %d, %Y'
  95. # List of patterns, relative to source directory, that match files and
  96. # directories to ignore when looking for source files.
  97. # This patterns also effect to html_static_path and html_extra_path
  98. exclude_patterns = [
  99. '_build',
  100. 'Thumbs.db',
  101. '.DS_Store',
  102. 'README.md',
  103. '**/alias.hpp',
  104. '**/config.hpp',
  105. '**/hof.hpp',
  106. '**/static_def.hpp',
  107. '**/test.hpp',
  108. '**/detail/*.hpp',
  109. ]
  110. # The reST default role (used for this markup: `text`) to use for all
  111. # documents.
  112. #
  113. # default_role = None
  114. # If true, '()' will be appended to :func: etc. cross-reference text.
  115. #
  116. # add_function_parentheses = True
  117. # If true, the current module name will be prepended to all description
  118. # unit titles (such as .. function::).
  119. #
  120. # add_module_names = True
  121. # If true, sectionauthor and moduleauthor directives will be shown in the
  122. # output. They are ignored by default.
  123. #
  124. # show_authors = False
  125. highlight_language = 'cpp'
  126. # The name of the Pygments (syntax highlighting) style to use.
  127. pygments_style = 'tango'
  128. # A list of ignored prefixes for module index sorting.
  129. # modindex_common_prefix = []
  130. # If true, keep warnings as "system message" paragraphs in the built documents.
  131. # keep_warnings = False
  132. # If true, `todo` and `todoList` produce output, else they produce nothing.
  133. todo_include_todos = False
  134. # -- Options for HTML output ----------------------------------------------
  135. # The theme to use for HTML and HTML Help pages. See the documentation for
  136. # a list of builtin themes.
  137. #
  138. # html_theme = 'alabaster'
  139. html_theme = 'boost'
  140. # Theme options are theme-specific and customize the look and feel of a theme
  141. # further. For a list of options available for each theme, see the
  142. # documentation.
  143. #
  144. # html_theme_options = {}
  145. # Add any paths that contain custom themes here, relative to this directory.
  146. html_theme_path = [sphinx_boost.get_html_theme_path()]
  147. # The name for this set of Sphinx documents.
  148. # "<project> v<release> documentation" by default.
  149. #
  150. # html_title = u'Boost.HigherOrderFunctions v1.0'
  151. # A shorter title for the navigation bar. Default is the same as html_title.
  152. #
  153. # html_short_title = None
  154. # The name of an image file (relative to this directory) to place at the top
  155. # of the sidebar.
  156. #
  157. # html_logo = 'boost-proposed.png'
  158. # The name of an image file (relative to this directory) to use as a favicon of
  159. # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  160. # pixels large.
  161. #
  162. # html_favicon = None
  163. # Add any paths that contain custom static files (such as style sheets) here,
  164. # relative to this directory. They are copied after the builtin static files,
  165. # so a file named "default.css" will overwrite the builtin "default.css".
  166. html_static_path = ['_static']
  167. # Add any extra paths that contain custom files (such as robots.txt or
  168. # .htaccess) here, relative to this directory. These files are copied
  169. # directly to the root of the documentation.
  170. #
  171. # html_extra_path = []
  172. # If not None, a 'Last updated on:' timestamp is inserted at every page
  173. # bottom, using the given strftime format.
  174. # The empty string is equivalent to '%b %d, %Y'.
  175. #
  176. # html_last_updated_fmt = None
  177. # If true, SmartyPants will be used to convert quotes and dashes to
  178. # typographically correct entities.
  179. #
  180. # html_use_smartypants = True
  181. # Custom sidebar templates, maps document names to template names.
  182. #
  183. # html_sidebars = {}
  184. # Additional templates that should be rendered to pages, maps page names to
  185. # template names.
  186. #
  187. html_additional_pages = {
  188. 'index': 'redirect.html',
  189. }
  190. # If false, no module index is generated.
  191. #
  192. # html_domain_indices = True
  193. # If false, no index is generated.
  194. #
  195. # html_use_index = True
  196. # If true, the index is split into individual pages for each letter.
  197. #
  198. # html_split_index = False
  199. # If true, links to the reST sources are added to the pages.
  200. #
  201. html_show_sourcelink = True
  202. html_copy_source = True
  203. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  204. #
  205. # html_show_sphinx = True
  206. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  207. #
  208. # html_show_copyright = True
  209. # If true, an OpenSearch description file will be output, and all pages will
  210. # contain a <link> tag referring to it. The value of this option must be the
  211. # base URL from which the finished HTML is served.
  212. #
  213. # html_use_opensearch = ''
  214. # This is the file name suffix for HTML files (e.g. ".xhtml").
  215. # html_file_suffix = None
  216. # Language to be used for generating the HTML full-text search index.
  217. # Sphinx supports the following languages:
  218. # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
  219. # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
  220. #
  221. # html_search_language = 'en'
  222. # A dictionary with options for the search language support, empty by default.
  223. # 'ja' uses this config value.
  224. # 'zh' user can custom change `jieba` dictionary path.
  225. #
  226. # html_search_options = {'type': 'default'}
  227. # The name of a javascript file (relative to the configuration directory) that
  228. # implements a search results scorer. If empty, the default will be used.
  229. #
  230. # html_search_scorer = 'scorer.js'
  231. # Output file base name for HTML help builder.
  232. htmlhelp_basename = 'Boost.HigherOrderFunctionsdoc'
  233. # -- Options for LaTeX output ---------------------------------------------
  234. latex_elements = {
  235. # The paper size ('letterpaper' or 'a4paper').
  236. #
  237. # 'papersize': 'letterpaper',
  238. # The font size ('10pt', '11pt' or '12pt').
  239. #
  240. # 'pointsize': '10pt',
  241. # Additional stuff for the LaTeX preamble.
  242. #
  243. # 'preamble': '',
  244. # Latex figure (float) alignment
  245. #
  246. # 'figure_align': 'htbp',
  247. }
  248. # Grouping the document tree into LaTeX files. List of tuples
  249. # (source start file, target name, title,
  250. # author, documentclass [howto, manual, or own class]).
  251. latex_documents = [
  252. (master_doc, 'Boost.HigherOrderFunctions.tex', u'Boost.HigherOrderFunctions Documentation',
  253. u'Paul Fultz II', 'manual'),
  254. ]
  255. # The name of an image file (relative to this directory) to place at the top of
  256. # the title page.
  257. #
  258. # latex_logo = None
  259. # For "manual" documents, if this is true, then toplevel headings are parts,
  260. # not chapters.
  261. #
  262. # latex_use_parts = False
  263. # If true, show page references after internal links.
  264. #
  265. # latex_show_pagerefs = False
  266. # If true, show URL addresses after external links.
  267. #
  268. # latex_show_urls = False
  269. # Documents to append as an appendix to all manuals.
  270. #
  271. # latex_appendices = []
  272. # If false, no module index is generated.
  273. #
  274. # latex_domain_indices = True
  275. # -- Options for manual page output ---------------------------------------
  276. # One entry per manual page. List of tuples
  277. # (source start file, name, description, authors, manual section).
  278. man_pages = [
  279. (master_doc, 'Boost.HigherOrderFunctions', u'Boost.HigherOrderFunctions Documentation',
  280. [author], 1)
  281. ]
  282. # If true, show URL addresses after external links.
  283. #
  284. # man_show_urls = False
  285. # -- Options for Texinfo output -------------------------------------------
  286. # Grouping the document tree into Texinfo files. List of tuples
  287. # (source start file, target name, title, author,
  288. # dir menu entry, description, category)
  289. texinfo_documents = [
  290. (master_doc, 'Boost.HigherOrderFunctions', u'Boost.HigherOrderFunctions Documentation',
  291. author, 'Boost.HigherOrderFunctions', 'One line description of project.',
  292. 'Miscellaneous'),
  293. ]
  294. # Documents to append as an appendix to all manuals.
  295. #
  296. # texinfo_appendices = []
  297. # If false, no module index is generated.
  298. #
  299. # texinfo_domain_indices = True
  300. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  301. #
  302. # texinfo_show_urls = 'footnote'
  303. # If true, do not generate a @detailmenu in the "Top" node's menu.
  304. #
  305. # texinfo_no_detailmenu = False
  306. nitpicky = True
  307. def insert_header(lines, f):
  308. for line in lines:
  309. yield line
  310. if line.startswith('=='):
  311. yield ""
  312. yield "Header"
  313. yield "------"
  314. yield ""
  315. yield " #include <{0}>".format(f)
  316. yield ""
  317. extract_prefix = '/// '
  318. include_dir = os.path.abspath('../include/')
  319. def extract_doc(app, docname, source):
  320. path = app.env.doc2path(docname)
  321. if path.endswith('.hpp'):
  322. lines = source[0].split('\n')
  323. md = [line[len(extract_prefix):] for line in lines if line.startswith(extract_prefix)]
  324. source[0] = '\n'.join(insert_header(md, os.path.relpath(path, include_dir)))
  325. # app setup hook
  326. def setup(app):
  327. app.srcdir = os.path.abspath(os.path.join(app.srcdir, os.pardir))
  328. app.add_config_value('recommonmark_config', {
  329. 'enable_eval_rst': True,
  330. # 'enable_auto_doc_ref': True,
  331. 'commonmark_suffixes': ['.md', '.hpp'],
  332. }, True)
  333. app.add_transform(AutoStructify)
  334. app.connect('source-read', extract_doc)