|
|
@ -1,21 +1,25 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
"""
|
|
|
|
# DFHack documentation build configuration file
|
|
|
|
DFHack documentation build configuration file
|
|
|
|
#
|
|
|
|
|
|
|
|
# This file is execfile()d with the current directory set to its
|
|
|
|
This file is execfile()d with the current directory set to its
|
|
|
|
# containing dir.
|
|
|
|
containing dir.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Note that not all possible configuration values are present in this
|
|
|
|
Note that not all possible configuration values are present in this
|
|
|
|
# autogenerated file.
|
|
|
|
autogenerated file.
|
|
|
|
#
|
|
|
|
|
|
|
|
# All configuration values have a default; values that are commented out
|
|
|
|
All configuration values have a default; values that are commented out
|
|
|
|
# serve to show the default.
|
|
|
|
serve to show the default.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pylint:disable=redefined-builtin
|
|
|
|
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
import fnmatch
|
|
|
|
from io import open
|
|
|
|
from io import open
|
|
|
|
|
|
|
|
from itertools import starmap
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import shlex
|
|
|
|
import shlex # pylint:disable=unused-import
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,10 +33,14 @@ def doc_dir(dirname, files):
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
with open(os.path.join(dirname, f), 'r', encoding='utf8') as fstream:
|
|
|
|
with open(os.path.join(dirname, f), 'r', encoding='utf8') as fstream:
|
|
|
|
text = [l.rstrip() for l in fstream.readlines() if l.strip()]
|
|
|
|
text = [l.rstrip() for l in fstream.readlines() if l.strip()]
|
|
|
|
|
|
|
|
# Some legacy lua files use the ruby tokens (in 3rdparty scripts)
|
|
|
|
|
|
|
|
tokens = ('=begin', '=end')
|
|
|
|
|
|
|
|
if f[-4:] == '.lua' and any('[====[' in line for line in text):
|
|
|
|
|
|
|
|
tokens = ('[====[', ']====]')
|
|
|
|
command = None
|
|
|
|
command = None
|
|
|
|
for line in text:
|
|
|
|
for line in text:
|
|
|
|
if command and line == len(line) * '=':
|
|
|
|
if command and line == len(line) * '=':
|
|
|
|
yield command, sdir + '/' + f
|
|
|
|
yield command, sdir + '/' + f, tokens[0], tokens[1]
|
|
|
|
break
|
|
|
|
break
|
|
|
|
command = line
|
|
|
|
command = line
|
|
|
|
|
|
|
|
|
|
|
@ -40,9 +48,7 @@ def doc_dir(dirname, files):
|
|
|
|
def document_scripts():
|
|
|
|
def document_scripts():
|
|
|
|
"""Autodoc for files with the magic script documentation marker strings.
|
|
|
|
"""Autodoc for files with the magic script documentation marker strings.
|
|
|
|
|
|
|
|
|
|
|
|
Creates a file for eack kind of script (base/devel/fix/gui/modtools)
|
|
|
|
Returns a dict of script-kinds to lists of .rst include directives.
|
|
|
|
with all the ".. include::" directives to pull out docs between the
|
|
|
|
|
|
|
|
magic strings.
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# First, we collect the commands and paths to include in our docs
|
|
|
|
# First, we collect the commands and paths to include in our docs
|
|
|
|
scripts = []
|
|
|
|
scripts = []
|
|
|
@ -55,15 +61,19 @@ def document_scripts():
|
|
|
|
if len(k_fname) == 1:
|
|
|
|
if len(k_fname) == 1:
|
|
|
|
kinds['base'].append(s)
|
|
|
|
kinds['base'].append(s)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
kinds.get(k_fname[0], []).append(s)
|
|
|
|
kinds[k_fname[0]].append(s)
|
|
|
|
template = ('.. _{}:\n\n'
|
|
|
|
template = '.. _{}:\n\n.. include:: /{}\n' +\
|
|
|
|
'.. include:: /{}\n'
|
|
|
|
' :start-after: {}\n :end-before: {}\n'
|
|
|
|
' :start-after: =begin\n'
|
|
|
|
return {key: '\n\n'.join(starmap(template.format, sorted(value)))
|
|
|
|
' :end-before: =end\n')
|
|
|
|
for key, value in kinds.items()}
|
|
|
|
for key, value in kinds.items():
|
|
|
|
|
|
|
|
kinds[key] = [template.format(x[0], x[1])
|
|
|
|
def write_script_docs():
|
|
|
|
for x in sorted(value, key=lambda x: x[0])]
|
|
|
|
"""
|
|
|
|
# Finally, we write our _auto/* files for each kind of script
|
|
|
|
Creates a file for eack kind of script (base/devel/fix/gui/modtools)
|
|
|
|
|
|
|
|
with all the ".. include::" directives to pull out docs between the
|
|
|
|
|
|
|
|
magic strings.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
kinds = document_scripts()
|
|
|
|
if not os.path.isdir('docs/_auto'):
|
|
|
|
if not os.path.isdir('docs/_auto'):
|
|
|
|
os.mkdir('docs/_auto')
|
|
|
|
os.mkdir('docs/_auto')
|
|
|
|
head = {
|
|
|
|
head = {
|
|
|
@ -76,15 +86,18 @@ def document_scripts():
|
|
|
|
title = ('.. _{k}:\n\n{l}\n{t}\n{l}\n\n'
|
|
|
|
title = ('.. _{k}:\n\n{l}\n{t}\n{l}\n\n'
|
|
|
|
'.. include:: /scripts/{a}about.txt\n\n'
|
|
|
|
'.. include:: /scripts/{a}about.txt\n\n'
|
|
|
|
'.. contents::\n\n').format(
|
|
|
|
'.. contents::\n\n').format(
|
|
|
|
k=k, t=head[k], l=len(head[k])*'#', a=('' if k=='base' else k+'/'))
|
|
|
|
k=k, t=head[k],
|
|
|
|
|
|
|
|
l=len(head[k])*'#',
|
|
|
|
|
|
|
|
a=('' if k == 'base' else k + '/')
|
|
|
|
|
|
|
|
)
|
|
|
|
mode = 'w' if sys.version_info.major > 2 else 'wb'
|
|
|
|
mode = 'w' if sys.version_info.major > 2 else 'wb'
|
|
|
|
with open('docs/_auto/{}.rst'.format(k), mode) as outfile:
|
|
|
|
with open('docs/_auto/{}.rst'.format(k), mode) as outfile:
|
|
|
|
outfile.write(title)
|
|
|
|
outfile.write(title)
|
|
|
|
outfile.write('\n\n'.join(kinds[k]))
|
|
|
|
outfile.write(kinds[k])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Actually call the docs generator
|
|
|
|
# Actually call the docs generator
|
|
|
|
document_scripts()
|
|
|
|
write_script_docs()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- General configuration ------------------------------------------------
|
|
|
|
# -- General configuration ------------------------------------------------
|
|
|
@ -135,7 +148,7 @@ author = 'The DFHack Team'
|
|
|
|
|
|
|
|
|
|
|
|
def get_version():
|
|
|
|
def get_version():
|
|
|
|
"""Return the DFHack version string, from CMakeLists.txt"""
|
|
|
|
"""Return the DFHack version string, from CMakeLists.txt"""
|
|
|
|
version = release = ''
|
|
|
|
version = release = '' #pylint:disable=redefined-outer-name
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open('CMakeLists.txt') as f:
|
|
|
|
with open('CMakeLists.txt') as f:
|
|
|
|
for s in f.readlines():
|
|
|
|
for s in f.readlines():
|
|
|
@ -157,11 +170,8 @@ version = release = get_version()
|
|
|
|
# Usually you set "language" from the command line for these cases.
|
|
|
|
# Usually you set "language" from the command line for these cases.
|
|
|
|
language = None
|
|
|
|
language = None
|
|
|
|
|
|
|
|
|
|
|
|
# There are two options for replacing |today|: either, you set today to some
|
|
|
|
# strftime format for |today| and 'Last updated on:' timestamp at page bottom
|
|
|
|
# non-false value, then it is used:
|
|
|
|
today_fmt = html_last_updated_fmt = '%Y-%m-%d'
|
|
|
|
#today = ''
|
|
|
|
|
|
|
|
# Else, today_fmt is used as the format for a strftime call.
|
|
|
|
|
|
|
|
#today_fmt = '%B %d, %Y'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# List of patterns, relative to source directory, that match files and
|
|
|
|
# List of patterns, relative to source directory, that match files and
|
|
|
|
# directories to ignore when looking for source files.
|
|
|
|
# directories to ignore when looking for source files.
|
|
|
@ -202,9 +212,6 @@ html_theme_options = {
|
|
|
|
'travis_button': False,
|
|
|
|
'travis_button': False,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Add any paths that contain custom themes here, relative to this directory.
|
|
|
|
|
|
|
|
#html_theme_path = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The name for this set of Sphinx documents. If None, it defaults to
|
|
|
|
# The name for this set of Sphinx documents. If None, it defaults to
|
|
|
|
# "<project> v<release> documentation".
|
|
|
|
# "<project> v<release> documentation".
|
|
|
|
#html_title = None
|
|
|
|
#html_title = None
|
|
|
@ -226,19 +233,6 @@ html_favicon = 'docs/styles/dfhack-icon.ico'
|
|
|
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
|
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
|
|
html_static_path = ['docs/styles']
|
|
|
|
html_static_path = ['docs/styles']
|
|
|
|
|
|
|
|
|
|
|
|
# Add any extra paths that contain custom files (such as robots.txt or
|
|
|
|
|
|
|
|
# .htaccess) here, relative to this directory. These files are copied
|
|
|
|
|
|
|
|
# directly to the root of the documentation.
|
|
|
|
|
|
|
|
#html_extra_path = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
|
|
|
|
|
|
|
# using the given strftime format.
|
|
|
|
|
|
|
|
html_last_updated_fmt = '%Y-%m-%d'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
|
|
|
|
|
|
|
# typographically correct entities.
|
|
|
|
|
|
|
|
#html_use_smartypants = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Custom sidebar templates, maps document names to template names.
|
|
|
|
# Custom sidebar templates, maps document names to template names.
|
|
|
|
html_sidebars = {
|
|
|
|
html_sidebars = {
|
|
|
|
'**': [
|
|
|
|
'**': [
|
|
|
@ -249,113 +243,18 @@ html_sidebars = {
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Additional templates that should be rendered to pages, maps page names to
|
|
|
|
|
|
|
|
# template names.
|
|
|
|
|
|
|
|
#html_additional_pages = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If false, no module index is generated.
|
|
|
|
# If false, no module index is generated.
|
|
|
|
html_domain_indices = False
|
|
|
|
html_domain_indices = False
|
|
|
|
|
|
|
|
|
|
|
|
# If false, no index is generated.
|
|
|
|
# If false, no index is generated.
|
|
|
|
html_use_index = False
|
|
|
|
html_use_index = False
|
|
|
|
|
|
|
|
|
|
|
|
# If true, the index is split into individual pages for each letter.
|
|
|
|
|
|
|
|
#html_split_index = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, links to the reST sources are added to the pages.
|
|
|
|
|
|
|
|
#html_show_sourcelink = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
|
|
|
|
|
|
|
#html_show_sphinx = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
|
|
|
|
|
|
|
#html_show_copyright = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, an OpenSearch description file will be output, and all pages will
|
|
|
|
|
|
|
|
# contain a <link> tag referring to it. The value of this option must be the
|
|
|
|
|
|
|
|
# base URL from which the finished HTML is served.
|
|
|
|
|
|
|
|
#html_use_opensearch = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Output file base name for HTML help builder.
|
|
|
|
|
|
|
|
htmlhelp_basename = 'DFHackdoc'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Options for LaTeX output ---------------------------------------------
|
|
|
|
# -- Options for LaTeX output ---------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
latex_elements = {
|
|
|
|
|
|
|
|
# The paper size ('letterpaper' or 'a4paper').
|
|
|
|
|
|
|
|
#'papersize': 'letterpaper',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The font size ('10pt', '11pt' or '12pt').
|
|
|
|
|
|
|
|
#'pointsize': '10pt',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Additional stuff for the LaTeX preamble.
|
|
|
|
|
|
|
|
#'preamble': '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Latex figure (float) alignment
|
|
|
|
|
|
|
|
#'figure_align': 'htbp',
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Grouping the document tree into LaTeX files. List of tuples
|
|
|
|
# Grouping the document tree into LaTeX files. List of tuples
|
|
|
|
# (source start file, target name, title,
|
|
|
|
# (source start file, target name, title,
|
|
|
|
# author, documentclass [howto, manual, or own class]).
|
|
|
|
# author, documentclass [howto, manual, or own class]).
|
|
|
|
latex_documents = [
|
|
|
|
latex_documents = [
|
|
|
|
(master_doc, 'DFHack.tex', 'DFHack Documentation',
|
|
|
|
(master_doc, 'DFHack.tex', 'DFHack Documentation',
|
|
|
|
'The DFHack Team', 'manual'),
|
|
|
|
'The DFHack Team', 'manual'),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# The name of an image file (relative to this directory) to place at the top of
|
|
|
|
|
|
|
|
# the title page.
|
|
|
|
|
|
|
|
#latex_logo = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
|
|
|
|
|
|
|
# not chapters.
|
|
|
|
|
|
|
|
#latex_use_parts = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, show page references after internal links.
|
|
|
|
|
|
|
|
#latex_show_pagerefs = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, show URL addresses after external links.
|
|
|
|
|
|
|
|
#latex_show_urls = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Documents to append as an appendix to all manuals.
|
|
|
|
|
|
|
|
#latex_appendices = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If false, no module index is generated.
|
|
|
|
|
|
|
|
#latex_domain_indices = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Options for manual page output ---------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# One entry per manual page. List of tuples
|
|
|
|
|
|
|
|
# (source start file, name, description, authors, manual section).
|
|
|
|
|
|
|
|
man_pages = [
|
|
|
|
|
|
|
|
(master_doc, 'dfhack', 'DFHack Documentation',
|
|
|
|
|
|
|
|
[author], 1)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, show URL addresses after external links.
|
|
|
|
|
|
|
|
#man_show_urls = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Options for Texinfo output -------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Grouping the document tree into Texinfo files. List of tuples
|
|
|
|
|
|
|
|
# (source start file, target name, title, author,
|
|
|
|
|
|
|
|
# dir menu entry, description, category)
|
|
|
|
|
|
|
|
texinfo_documents = [
|
|
|
|
|
|
|
|
(master_doc, 'DFHack', 'DFHack Documentation',
|
|
|
|
|
|
|
|
author, 'DFHack', 'One line description of project.',
|
|
|
|
|
|
|
|
'Miscellaneous'),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Documents to append as an appendix to all manuals.
|
|
|
|
|
|
|
|
#texinfo_appendices = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If false, no module index is generated.
|
|
|
|
|
|
|
|
#texinfo_domain_indices = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
|
|
|
|
|
|
|
#texinfo_show_urls = 'footnote'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
|
|
|
|
|
|
|
#texinfo_no_detailmenu = False
|
|
|
|
|
|
|
|