Files
lammps/doc/utils/sphinx-config/conf.py.in

561 lines
18 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# LAMMPS documentation build configuration file, created by
# sphinx-quickstart on Sat Sep 6 14:20:08 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
from datetime import date
has_enchant = False
try:
import enchant
has_enchant = True
except:
pass
LAMMPS_DOC_DIR = '@LAMMPS_DOC_DIR@'
LAMMPS_SOURCE_DIR = '@LAMMPS_SOURCE_DIR@'
LAMMPS_PYTHON_DIR = '@LAMMPS_PYTHON_DIR@'
LAMMPS_DOXYGEN_XML_DIR = '@DOXYGEN_XML_DIR@'
# 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.join(LAMMPS_DOC_DIR, 'src', '_ext'))
# add lammps_theme
sys.path.append(os.path.join(LAMMPS_DOC_DIR, 'utils', 'sphinx-config', '_themes'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '5.3.0'
# 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.mathjax',
'sphinx.ext.imgmath',
'sphinx.ext.autodoc',
'sphinx_toolbox.collapse',
'lammps_theme',
'sphinxcontrib.jquery',
'sphinxfortran.fortran_domain',
'sphinx_tabs.tabs',
'table_from_list',
'tab_or_note',
'breathe',
'sphinx_design'
]
images_config = {
'default_image_width' : '25%',
'default_group' : 'default'
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = {'.rst': 'restructuredtext'}
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'Manual'
# General information about the project.
project = 'LAMMPS'
copyright = '2003-{} Sandia Corporation'.format(date.today().year)
def get_lammps_version():
import os
script_dir = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(LAMMPS_SOURCE_DIR, 'version.h'), 'r') as f:
line = f.readline()
start_pos = line.find('"')+1
end_pos = line.find('"', start_pos)
return line[start_pos:end_pos]
def get_lammps_update():
import os
script_dir = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(LAMMPS_SOURCE_DIR, 'version.h'), 'r') as f:
line = f.readline()
line = f.readline()
start_pos = line.find('"')+1
end_pos = line.find('"', start_pos)
return line[start_pos:end_pos]
def get_git_info():
import subprocess,time
git_n_date = ''
try:
gitinfo = subprocess.run(['git','describe'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
if gitinfo.returncode == 0:
git_n_date = gitinfo.stdout.decode().replace('_',' ').replace('patch ','').replace('stable ','')
except:
pass
return git_n_date.strip()
def get_git_commit():
import subprocess,time
try:
commit = subprocess.run(['git','rev-parse','HEAD'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
if commit.returncode == 0:
return commit.stdout.decode()
except:
pass
return ''
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = get_lammps_version()
# The full version, including alpha/beta/rc tags.
release = get_git_info()
git_commit = get_git_commit()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
language = 'en'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#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
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'default'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'lammps_theme'
# 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
# documentation.
html_theme_options = {
'logo_only' : True,
'navigation_depth': 3,
'collapse_navigation': True
}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_themes']
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = "LAMMPS documentation"
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = '_static/lammps-logo.png'
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = '_static/lammps.ico'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static',]
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = ['css/lammps.css',]
# 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 = '%b %d, %Y'
# 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.
#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.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# 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 = False
# 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 = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'LAMMPSdoc'
html_permalinks = True
# 2022-12-30:
# "Canonical" is always the "current" version of the LAMMPS online manual.
# Changing this depending on whether this is for the development or stable
# version is confusing search engines. So this is the URL to point to.
# This fixed setting should reduce the number of URLs that Google complains
# about as having a canonical URLs where it chooses a different one.
html_baseurl = 'https://docs.lammps.org/'
if 'epub' in sys.argv:
html_math_renderer = 'imgmath'
else:
html_math_renderer = 'mathjax'
# use relative path for mathjax, so it is looked for in the
# html tree and the manual becomes readable when offline
mathjax_path = 'mathjax/es5/tex-mml-chtml.js'
# hack to enable use of \AA in :math:
# add :lammps: role for inline LAMMPS code highlight
rst_prolog = r"""
.. only:: html
:math:`\renewcommand{\AA}{\text{Å}}`
.. role:: lammps(code)
:language: LAMMPS
:class: highlight
"""
# -- Options for LaTeX output ---------------------------------------------
latex_engine = 'pdflatex'
if (get_lammps_update() == 'Development') or (get_lammps_update() == 'Maintenance'):
if get_git_info() == '':
lammpsversion = format("\\newcommand{\\lammpsversion}{%s %s}\n" \
% (get_lammps_update(), get_lammps_version()))
else:
lammpsversion = format("\\newcommand{\\lammpsversion}{Git: %s}\n" % (get_git_info()))
else:
lammpsversion = format("\\newcommand{\\lammpsversion}{Release %s %s}\n" \
% (get_lammps_version(), get_lammps_update()))
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': r'''
\setcounter{tocdepth}{2}
\setcounter{part}{-1}
\renewcommand{\sfdefault}{ptm} % Use Times New Roman font for \textrm
\renewcommand{\sfdefault}{phv} % Use Helvetica font for \textsf
\usepackage[columns=1]{idxlayout} % create index with only one column
% Set up math fonts to match text fonts
\DeclareSymbolFont{operators} {OT1}{ptm}{m}{n}
\DeclareSymbolFont{bold} {OT1}{ptm}{bx}{n}
\DeclareSymbolFont{italic} {OT1}{ptm}{m}{it}
\DeclareSymbolFont{extraops} {OT1}{ztmcm}{m}{n}
\DeclareSymbolFont{letters} {OML}{ztmcm}{m}{it}
\DeclareSymbolFont{largesymbols}{OMX}{ztmcm}{m}{n}
% symbols (and \mathcal) are taken from computer modern.
% setup mappings
\DeclareSymbolFontAlphabet{\mathrm} {operators}
\DeclareSymbolFontAlphabet{\mathnormal}{letters}
\DeclareMathAlphabet{\mathnormal}{OT1}{ptm}{m}{n}
\DeclareMathAlphabet{\mathrm}{OT1}{ptm}{m}{n}
\DeclareMathAlphabet{\mathbf}{OT1}{ptm}{bx}{n}
\DeclareMathAlphabet{\mathit}{OT1}{ptm}{m}{it}
\DeclareMathAlphabet{\mathtt}{OT1}{pcr}{m}{n}
\SetMathAlphabet\mathit{bold}{OT1}{ptm}{bx}{it}
% declare missing operators
\DeclareMathSymbol{\omicron}{0}{operators}{`\o}
\DeclareMathSymbol{\Gamma}{\mathalpha}{extraops}{"00}
\DeclareMathSymbol{\Delta}{\mathalpha}{extraops}{"01}
\DeclareMathSymbol{\Theta}{\mathalpha}{extraops}{"02}
\DeclareMathSymbol{\Lambda}{\mathalpha}{extraops}{"03}
\DeclareMathSymbol{\Xi}{\mathalpha}{extraops}{"04}
\DeclareMathSymbol{\Pi}{\mathalpha}{extraops}{"05}
\DeclareMathSymbol{\Sigma}{\mathalpha}{extraops}{"06}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{extraops}{"07}
\DeclareMathSymbol{\Phi}{\mathalpha}{extraops}{"08}
\DeclareMathSymbol{\Psi}{\mathalpha}{extraops}{"09}
\DeclareMathSymbol{\Omega}{\mathalpha}{extraops}{"0A}
\renewcommand{\AA}{\mbox{\textrm{\r{A}}}}
% Make ToC number fields wider to accommodate sections with >= 100 subsections
% or >= 10 subsections with >= 10 subsubsections
\makeatletter
% reset chapter counter for each part
\@addtoreset{chapter}{part}
\renewcommand*{\sphinxtableofcontentshook}{%
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{3.1em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{4.6em}{4.5em}}
}
\makeatother
''',
'maketitle': lammpsversion + r'''
% customized titlepage
{%
\hypersetup{pageanchor=false}% avoid duplicate destination warnings
\begin{titlepage}%
\sffamily\Large
The LAMMPS developers are thinking about dropping the PDF format version of
the LAMMPS manual. This would allow us to focus on the HTML version, use
HTML-only features, and skip checking if the documentation source files,
especially the embedded mathematical expressions, are compatible with \LaTeX{} output.
Please let us know how you feel about this change by sending an email to
\texttt{developers@lammps.org} stating whether you agree or disagree with
removing support for the PDF format version of the manual and optionally
provide arguments for your preference.
\clearpage
\sffamily\bfseries
\begingroup % for PDF information dictionary
\def\endgraf{ }\def\and{\& }%
\pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup
\hypersetup{pdfauthor={The LAMMPS Developers}, pdftitle={LAMMPS Documentation}}%
\endgroup
\noindent\rule{\textwidth}{4pt}\par
\begin{center}%
\sphinxlogo
\vfill
{\Huge LAMMPS Documentation \par}
\vfill
{\LARGE \lammpsversion \par}
\vfill
{\LARGE The LAMMPS Developers \par}
{\Large developers@lammps.org $^*$ \par}
\vfill\vfill\vfill
{\normalsize ${}^*$ see
\sphinxhref{https://www.lammps.org/authors.html}{https://www.lammps.org/authors.html}
for details \par}
\end{center}
\noindent\rule{\textwidth}{4pt}\par
\end{titlepage}%
\setcounter{footnote}{0}%
\clearpage
}
''',
}
# copy custom style file for tweaking index layout
latex_additional_files = [
'latex/idxlayout.sty', 'latex/ellipse.sty',
'latex/pict2e.sty', 'latex/p2e-pdftex.def',
]
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('Manual', 'LAMMPS.tex', 'LAMMPS Documentation',
'The LAMMPS Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = "_static/lammps-logo-large.png"
latex_toplevel_sectioning = 'part'
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
latex_show_urls = 'no'
# If false, no module index is generated.
latex_domain_indices = False
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('Manual', 'lammps', 'LAMMPS Documentation',
['Steve Plimpton'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# strip off LAMMPS_NS:: from index entries
cpp_index_common_prefix = [
'LAMMPS_NS::',
'_LMP_STYLE_CONST::', '_LMP_TYPE_CONST::', '_LMP_VAR_CONST::',
]
# -- 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 = [
('Manual', 'LAMMPS', 'LAMMPS Documentation',
'LAMMPS', '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
# -- Options for ePUB output ----------------------------------------------
epub_title = 'LAMMPS Documentation - ' + get_lammps_version()
epub_cover = ('_static/lammps-logo.png', '')
epub_description = """
This is the Manual for the LAMMPS software package.
LAMMPS stands for Large-scale Atomic/Molecular Massively Parallel
Simulator and is a classical molecular dynamics simulation code
designed to run efficiently on parallel computers. It was developed
at Sandia National Laboratories, a US Department of Energy facility,
with funding from the DOE. It is an open-source code, distributed
freely under the terms of the GNU Public License (GPL).
The LAMMPS developers can be contacted at developers@lammps.org.
The LAMMPS WWW Site at www.lammps.org has more information about
the code and its uses.
"""
epub_author = 'The LAMMPS Developers'
# configure spelling extension if present
import importlib.util
spelling_spec = importlib.util.find_spec("sphinxcontrib.spelling")
if spelling_spec and has_enchant:
extensions.append('sphinxcontrib.spelling')
spelling_lang='en_US'
spelling_word_list_filename='false_positives.txt'
conf_script_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(conf_script_dir, '.'))
import LAMMPSLexer
from sphinx.highlighting import lexers
lexers['LAMMPS'] = LAMMPSLexer.LAMMPSLexer(startinline=True)
sys.path.insert(1,LAMMPS_PYTHON_DIR)
# avoid syntax highlighting in blocks that don't specify language
highlight_language = 'none'
# autodoc configuration
autodoc_member_order = 'bysource'
#autoclass_content = 'both'
# breathe configuration
breathe_projects = { 'progguide' : LAMMPS_DOXYGEN_XML_DIR }
breathe_default_project = 'progguide'
breathe_show_define_initializer = True
breathe_domain_by_extension = { 'h' : 'cpp',
'cpp' : 'cpp',
'c' : 'c',
}
# allows showing multiple versions
try:
html_context
except NameError:
html_context = dict()
is_website_build = os.environ.get('LAMMPS_WEBSITE_BUILD', '0') != '0'
html_context['display_manual_versions'] = is_website_build
html_context['current_version'] = os.environ.get('LAMMPS_WEBSITE_BUILD_VERSION', version)
html_context['git_commit'] = git_commit
html_context['versions'] = [
('latest', 'https://docs.lammps.org/latest/'),
('stable', 'https://docs.lammps.org/stable/'),
(version, 'https://docs.lammps.org/')
]
html_context['downloads'] = [('PDF', 'Manual.pdf')]