Read stable release citation from CITATION.cff Restore CITATION.cff to the latest published stable release (2.2, released 2023-10-13) and parse version, year, and month from CITATION.cff in docs/source/conf.py for the BibTeX citation in docs/source/index.rst. This keeps include/ceres/version.h tracking the development API version on master while CITATION.cff and docs/source/index.rst track the latest stable release. Change-Id: Id22e8c56ac30deaf149cb3533e5e26ffa49cc34f
diff --git a/CITATION.cff b/CITATION.cff index b8d4a39..d780ff3 100644 --- a/CITATION.cff +++ b/CITATION.cff
@@ -8,7 +8,7 @@ - family-names: Mierle given-names: Keir - name: The Ceres Solver Team -version: 2.3 +version: 2.2 date-released: 2023-10-13 license: BSD-3-Clause repository-code: https://github.com/ceres-solver/ceres-solver
diff --git a/docs/source/conf.py b/docs/source/conf.py index edd9dc4..bdb337d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py
@@ -2,9 +2,10 @@ import re # Parse version from include/ceres/version.h so it stays in sync automatically. -_version_header = ( - Path(__file__).resolve().parents[2] / 'include' / 'ceres' / 'version.h' -).read_text(encoding='utf-8') +_repo_root = Path(__file__).resolve().parents[2] +_version_header = (_repo_root / 'include' / 'ceres' / 'version.h').read_text( + encoding='utf-8' +) _major = re.search( r'#define\s+CERES_VERSION_MAJOR\s+(\d+)', _version_header ).group(1) @@ -21,6 +22,23 @@ version = f'{_major}.{_minor}' release = f'{_major}.{_minor}.{_patch}' +# Parse the latest stable release metadata from CITATION.cff for index.rst. +_citation_cff = (_repo_root / 'CITATION.cff').read_text(encoding='utf-8') +_stable_version = re.search( + r'^version:\s*(\S+)', _citation_cff, re.MULTILINE +).group(1) +_stable_date = re.search( + r'^date-released:\s*(\d{4})-(\d{2})-\d{2}', _citation_cff, re.MULTILINE +) +_stable_year = _stable_date.group(1) +_stable_month = str(int(_stable_date.group(2))) + +rst_epilog = f""" +.. |stable_version| replace:: {_stable_version} +.. |stable_year| replace:: {_stable_year} +.. |stable_month| replace:: {_stable_month} +""" + extensions = [ 'sphinx.ext.todo', 'sphinx.ext.mathjax',
diff --git a/docs/source/index.rst b/docs/source/index.rst index 8aace14..cf51023 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst
@@ -44,16 +44,18 @@ Cite Us ======= -If you use Ceres Solver for a publication, please cite it as:: +If you use Ceres Solver for a publication, please cite it as: + +.. parsed-literal:: @software{Agarwal_Ceres_Solver_2022, author = {Agarwal, Sameer and Mierle, Keir and The Ceres Solver Team}, title = {{Ceres Solver}}, license = {BSD-3-Clause}, url = {https://github.com/ceres-solver/ceres-solver}, - version = {2.3}, - year = {2026}, - month = {10} + version = {|stable_version|}, + year = {|stable_year|}, + month = {|stable_month|} } .. rubric:: Footnotes