[Bf-blender-cvs] [1ec93507e13] master: API doc: Tweak sphinx to get date of source commit instead of build date.
Bastien Montagne
noreply at git.blender.org
Wed Apr 6 11:43:42 CEST 2022
Commit: 1ec93507e130d9e48aec5b74f84de0f0b2ab29c1
Author: Bastien Montagne
Date: Wed Apr 6 11:42:36 2022 +0200
Branches: master
https://developer.blender.org/rB1ec93507e130d9e48aec5b74f84de0f0b2ab29c1
API doc: Tweak sphinx to get date of source commit instead of build date.
This commit disables the 'last updated' value (which is the date the
sphinx doc is generated), and instead modifies the 'commit' field from
the 'html_context' data to get:
- a link to the commit itself.
- the date of that commit.
This avoids having the whole documentation detected as changed every
time it is re-generated by the buildbot.
Reviewed By: dfelinto, campbellbarton
Differential Revision: https://developer.blender.org/D14429
===================================================================
M doc/python_api/sphinx_doc_gen.py
===================================================================
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index b427fedebc1..b074ce77a39 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -63,6 +63,7 @@ import os
import sys
import inspect
import shutil
+import time
import logging
import warnings
@@ -399,6 +400,7 @@ MODULE_GROUPING = {
# converting bytes to strings, due to T30154
BLENDER_REVISION = str(bpy.app.build_hash, 'utf_8')
+BLENDER_REVISION_TIMESTAMP = bpy.app.build_commit_timestamp
# '2.83.0 Beta' or '2.83.0' or '2.83.1'
BLENDER_VERSION_STRING = bpy.app.version_string
@@ -407,9 +409,13 @@ BLENDER_VERSION_DOTS = "%d.%d" % (bpy.app.version[0], bpy.app.version[1])
if BLENDER_REVISION != "Unknown":
# SHA1 Git hash
BLENDER_VERSION_HASH = BLENDER_REVISION
+ BLENDER_VERSION_HASH_HTML_LINK = "<a href=https://developer.blender.org/rB%s>%s</a>" % (BLENDER_VERSION_HASH, BLENDER_VERSION_HASH)
+ BLENDER_VERSION_DATE = time.strftime("%d/%m/%Y", time.localtime(BLENDER_REVISION_TIMESTAMP))
else:
# Fallback: Should not be used
BLENDER_VERSION_HASH = "Hash Unknown"
+ BLENDER_VERSION_HASH_HTML_LINK = BLENDER_VERSION_HASH
+ BLENDER_VERSION_DATE = time.strftime("%Y-%m-%d")
# '2_83'
BLENDER_VERSION_PATH = "%d_%d" % (bpy.app.version[0], bpy.app.version[1])
@@ -1752,11 +1758,12 @@ except ModuleNotFoundError:
fw("html_split_index = True\n")
fw("html_static_path = ['static']\n")
fw("templates_path = ['templates']\n")
- fw("html_context = {'commit': '%s'}\n" % BLENDER_VERSION_HASH)
+ fw("html_context = {'commit': '%s - %s'}\n" % (BLENDER_VERSION_HASH_HTML_LINK, BLENDER_VERSION_DATE))
fw("html_extra_path = ['static/favicon.ico', 'static/blender_logo.svg']\n")
fw("html_favicon = 'static/favicon.ico'\n")
fw("html_logo = 'static/blender_logo.svg'\n")
- fw("html_last_updated_fmt = '%m/%d/%Y'\n\n")
+ # Disable default `last_updated` value, since this is the date of doc generation, not the one of the source commit.
+ fw("html_last_updated_fmt = None\n\n")
fw("if html_theme == 'sphinx_rtd_theme':\n")
fw(" html_css_files = ['css/version_switch.css']\n")
fw(" html_js_files = ['js/version_switch.js']\n")
More information about the Bf-blender-cvs
mailing list