Mercurial > hgrepos > Python > libs > ConfigMix
changeset 781:236a1d00b8a6
Some documentation tweaks: sync with other projects
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 16 May 2026 14:59:46 +0200 |
| parents | 47ae57d92ed3 |
| children | 36d9f5164046 |
| files | README.txt docs/conf.py |
| diffstat | 2 files changed, 59 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Sat May 16 13:04:04 2026 +0200 +++ b/README.txt Sat May 16 14:59:46 2026 +0200 @@ -9,7 +9,7 @@ All rights reserved. :License: BSD 3-Clause "New" or "Revised" License. See :ref:`LICENSE.txt <license>` for more details. -:Revision: |VCSHGrevision| +:Revision: |VCSRevision| "ConfigMix" is a library to help with the configuration of
--- a/docs/conf.py Sat May 16 13:04:04 2026 +0200 +++ b/docs/conf.py Sat May 16 14:59:46 2026 +0200 @@ -15,6 +15,7 @@ import datetime import os import sys + sys.path.insert(0, os.path.dirname(os.path.abspath('.'))) import configmix @@ -30,14 +31,49 @@ copyright = u('2015–2023, Franz Glasner. All rights reserved') author = 'Franz Glasner' -# The short X.Y version -version = '.'.join(configmix.__version__.split('.')[:2]) +current_date = datetime.date.today().isoformat() + # The full version, including alpha/beta/rc tags release = configmix.__version__ -release_date = today = configmix.__date__ +# The short X.Y version +version = '.'.join(release.split('.')[:2]) + +# +# Optimistically assume that all keywords are expanded properly everywhere: +# do not define special VCSxxx keyword below. +# +define_rest_keywords = False -current_date = datetime.date.today().isoformat() - +release_date = today = configmix.__date__ +if (not release_date + or (release_date.startswith("|") and release_date.endswith("|"))): + # Above assumption is not true: "hg kwarchive" nay not have been called + release_date = today = "dev-%s" % (current_date,) + define_rest_keywords = True +release_rev = configmix.__revision__ +if (not release_rev + or (release_rev.startswith("|") and release_rev.endswith("|"))): + # + # Above assumption is not true: "hg kwarchive" may not have been called. + # Try to determine from VCS. + # + import subprocess + try: + release_rev = subprocess.check_output( + ["hg", "id", "-i"], stderr=subprocess.STDOUT) + except Exception: + release_rev = "<UNKNOWN>" + else: + if sys.version_info[0] >= 3: + release_rev = release_rev.decode("ascii") + release_rev = "dev-%s" % (release_rev.strip(),) + define_rest_keywords = True +else: + # + # Assume that all keywords are expanded properly everywhere: + # do not define special VCSxxx keyword below. + # + define_rest_keywords = False # -- General configuration --------------------------------------------------- @@ -86,6 +122,17 @@ # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' +rst_prolog = """ +.. |release_date| replace:: %s +.. |release_rev| replace:: %s +""" % (release_date, release_rev) +if define_rest_keywords: + rst_prolog += """\ +.. |VCSJustDate| replace:: %s +.. |VCSRevision| replace:: %s +.. |VCSHGRevision| replace:: %s +""" % (release_date, release_rev, release_rev) + # -- Options for HTML output ------------------------------------------------- @@ -96,7 +143,7 @@ html_theme = 'haiku' # for the Haiku title html_short_title = u("%s %s") % (project, release) -html_last_updated_fmt = "%s (rev %s)" % (current_date, configmix.__revision__) +html_last_updated_fmt = "%s (rev %s)" % (current_date, release_rev) # 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 @@ -146,7 +193,7 @@ 'babel': r'\usepackage{babel}', 'preamble': r'\usepackage[stdtitle=false]{my-doc-style}', 'maketitle': r'\builddate{%s}\vcsrevision{%s}\sphinxmaketitle' \ - % (current_date, configmix.__revision__), + % (current_date, release_rev), 'fontpkg': r'\usepackage[fonts=charter]{my-doc-fonts}', # Latex figure (float) alignment @@ -159,7 +206,7 @@ } latex_additional_files = [ "_latex/my-doc-fonts.sty", - "_latex/my-doc-style.sty", + "_latex/my-doc-style.sty", ] # Grouping the document tree into LaTeX files. List of tuples @@ -219,8 +266,10 @@ def setup(app): # # Custom release_date variable with a custom substitution |release_date| + # and |release_rev|'. # app.add_config_value('release_date', '', 'env') + app.add_config_value('release_rev', '', 'env') import sphinx.transforms @@ -231,7 +280,7 @@ from docutils import nodes for ref in self.document.traverse(nodes.substitution_reference): refname = ref['refname'] - if refname == 'release_date': + if refname in ('release_date' 'release_rev'): stext = self.config[refname] ref.replace_self(nodes.Text(stext, stext))
