Mercurial > hgrepos > Python > libs > ConfigMix
changeset 163:ff03cdf36139
The README.txt should be in the most important parts readable without keyword substitutions.
The release number ist now directly included. Distinguish between the release
date "release_date" and the build date of the documentation "today".
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 14 Mar 2019 00:13:59 +0100 |
| parents | 4ce8ff2af612 |
| children | f8464559b838 |
| files | .hgkwarchive README.txt configmix/__init__.py doc/conf.py |
| diffstat | 4 files changed, 31 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgkwarchive Thu Feb 21 23:25:15 2019 +0100 +++ b/.hgkwarchive Thu Mar 14 00:13:59 2019 +0100 @@ -1,4 +1,4 @@ [patterns] -configmix/**.py = +configmix/**.py = RCS, reST path:README.txt = reST path:doc/conf.py =
--- a/README.txt Thu Feb 21 23:25:15 2019 +0100 +++ b/README.txt Thu Mar 14 00:13:59 2019 +0100 @@ -3,8 +3,8 @@ .. _README: :Author: Franz Glasner -:Version: |release| -:Date: |today| +:Version: 0.6.0.dev1 +:Date: |VCSJustDate| :Copyright: (c) 2015–2019, Franz Glasner. All rights reserved. :License: 3-clause BSD License.
--- a/configmix/__init__.py Thu Feb 21 23:25:15 2019 +0100 +++ b/configmix/__init__.py Thu Mar 14 00:13:59 2019 +0100 @@ -15,7 +15,8 @@ __version__ = "0.6.0.dev1" -__revision__ = "$Revision$" +__revision__ = "|VCSRevision|" +__date__ = "|VCSJustDate|" import copy
--- a/doc/conf.py Thu Feb 21 23:25:15 2019 +0100 +++ b/doc/conf.py Thu Mar 14 00:13:59 2019 +0100 @@ -12,6 +12,7 @@ # 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. # +import datetime import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath('.'))) @@ -30,14 +31,9 @@ version = '.'.join(configmix.__version__.split('.')[:2]) # The full version, including alpha/beta/rc tags release = configmix.__version__ +release_date = configmix.__date__ -today = '$Date$' -if len(today) == 6 \ - and today[0] == '$' and today[1:-2] == 'Date' \ - and today[-1] == '$': - del today -else: - today = today[7:today.find(' ', 7)] +today = datetime.date.today().isoformat() # -- General configuration --------------------------------------------------- @@ -95,6 +91,7 @@ html_theme = 'haiku' # for the Haiku title html_short_title = u("%s %s") % (project, release) +html_last_updated_fmt = "%s (rev %s)" % (today, configmix.__revision__) # 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 @@ -215,3 +212,25 @@ # -- Options for changelog --------------------------------------------------- changelog_inner_tag_sort = ['breaking', 'feature', 'bugfix', 'test', 'doc'] + + +def setup(app): + # + # Custom release_date variable with a custom substitution |release_date| + # + app.add_config_value('release_date', '', 'env') + + import sphinx.transforms + + class IAMCustomSubstitutions(sphinx.transforms.SphinxTransform): + + default_priority = sphinx.transforms.DefaultSubstitutions.default_priority + def apply(self): + from docutils import nodes + for ref in self.document.traverse(nodes.substitution_reference): + refname = ref['refname'] + if refname == 'release_date': + stext = self.config[refname] + ref.replace_self(nodes.Text(stext, stext)) + + app.add_transform(IAMCustomSubstitutions)
