Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 167:ddefcc20367c
More static and/or dynamic metadata into README and project's init: release date, revision.
While there bump the version to 3.0.0.dev1.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 10 May 2026 15:27:18 +0200 |
| parents | 6a7dace0141e |
| children | bff8b900713a |
| files | .hgignore .hgkwarchive Makefile README.rst docs/conf.py pygments_lexer_pseudocode2/__init__.py |
| diffstat | 6 files changed, 77 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Fri May 08 23:54:06 2026 +0200 +++ b/.hgignore Sun May 10 15:27:18 2026 +0200 @@ -6,4 +6,5 @@ (^|/)_tmp/ ^dist/ ^[^/.]+\.egg-info/ +^__arch.*/ ^docs/_build/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgkwarchive Sun May 10 15:27:18 2026 +0200 @@ -0,0 +1,3 @@ +[patterns] +pygments_lexer_pseudocode2/__init__.py = reST +path:README.rst = reST
--- a/Makefile Fri May 08 23:54:06 2026 +0200 +++ b/Makefile Sun May 10 15:27:18 2026 +0200 @@ -4,10 +4,10 @@ # SPDX-License-Identifier: MIT # :- -.PHONY: help all clean distclean dist build tests flake8 docs clean-docs clean-docs-html install-dev install-docs +.PHONY: help all clean distclean dist export build tests flake8 docs clean-docs clean-docs-html install-dev install-docs help: - @echo Targets: help, clean, distclean, dist, build + @echo Targets: help, clean, distclean, export, dist, build, tests docs clean-docs all: tests flake8 @@ -19,6 +19,10 @@ distclean: clean rm -rf dist/ *.egg-info +export: + rm -rf __arch + hg kwarchive __arch + clean: rm -rf __arch/ find . -name '*.pyc' -delete
--- a/README.rst Fri May 08 23:54:06 2026 +0200 +++ b/README.rst Sun May 10 15:27:18 2026 +0200 @@ -4,6 +4,11 @@ README -- Pseudocode Lexer for Pygments ***************************************** +:Version: 3.0.0.dev1 +:Date: |VCSJustDate| +:Revision: |VCSRevision| +:License: MIT License + This package contains `Pygments`_ lexers for some basic pseudocode. Initially a fork of `pygments-lexer-pseudocode` it has been considerably
--- a/docs/conf.py Fri May 08 23:54:06 2026 +0200 +++ b/docs/conf.py Sun May 10 15:27:18 2026 +0200 @@ -4,6 +4,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import ast +import datetime import functools import io import os @@ -20,25 +21,58 @@ """ +today = datetime.date.today().isoformat() # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = 'Pygments Pseudocode Lexer' -copyright = '2026 Franz Glasner. © Copyright 2015 Simon Wachter' +copyright = u'2026 Franz Glasner. © Copyright 2015 Simon Wachter' author = 'Franz Glasner' -# Determine "release" dynamically from the package's "__version__" +# +# Determine "release" and other release metadata dynamically from the +# package's "__version__" or other VCS data. +# with io.open("../pygments_lexer_pseudocode2/__init__.py", "rt", encoding="utf-8") as relfp: + verfiledata = relfp.read() release = ast.literal_eval( re.search(r"""^\s*__version__\s*=\s*(("|')[^"']*\2)""", - relfp.read(), - re.MULTILINE) - .group(1) - ) + verfiledata, + re.MULTILINE).group(1)) + release_date = ( + ast.literal_eval( + re.search(r"""^\s*__date__\s*=\s*(("|')[^"']*\2)""", + verfiledata, + re.MULTILINE).group(1)) + or "dev:%s" % (today,) + ) + release_rev = ast.literal_eval( + re.search(r"""^\s*__revision__\s*=\s*(("|')[^"']*\2)""", + verfiledata, + re.MULTILINE).group(1)) + if release_rev.startswith("|") or release_rev.endswith("|"): + # Assume that make export (hg kwarchive) is not called. + 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 + version = release -del relfp primary_domain = None # -- General configuration --------------------------------------------------- @@ -55,7 +89,14 @@ rst_prolog = """ .. role:: algpseudocode(code) -""" +.. |release_date| replace:: %s +.. |release_rev| replace:: %s +""" % (release_date, release_rev) +if define_rest_keywords: + rst_prolog += """\ +.. |VCSJustDate| replace:: %s +.. |VCSRevision| replace:: %s +""" % (release_date, release_rev) rst_epilog = """ .. _Pygments: https://pygments.org/ .. _Sphinx: https://www.sphinx-doc.org @@ -73,17 +114,27 @@ html_static_path = ['_static'] html_extra_path = ['../LICENSES', './examples'] +html_copy_source = False +html_show_sourcelink = False #html_theme = 'alabaster' html_theme = 'haiku' html_title = 'The %s v%s' % (project, release) html_short_title = html_title +html_last_updated_fmt = "%s (rv:%s)" % (today, release_rev) #pygments_style = "sphinx" pygments_style = "default" def setup(app): # + # Custom release_date and commit id variables with a custom substitution + # |release_date| and |release_rev|'. + # + app.add_config_value('release_date', '', 'env') + app.add_config_value('release_rev', '', 'env') + + # # Add a custom lexer: AlgPseudocodeLexer with custom init option "no_end" # Given lexer must be callable: so use an indirection with "partial". #
--- a/pygments_lexer_pseudocode2/__init__.py Fri May 08 23:54:06 2026 +0200 +++ b/pygments_lexer_pseudocode2/__init__.py Sun May 10 15:27:18 2026 +0200 @@ -12,4 +12,6 @@ <http://opensource.org/licenses/MIT>. """ -__version__ = "2.0.1" +__version__ = "3.0.0.dev1" +__date__ = "" # release date in ISO format +__revision__ = "|VCSRevision|"
