1
我需要增加每个编译版本的计数并显示当前日期并以表格的形式显示。我可以使用conf.py在sphinx文档中显示版本历史记录表吗?
我需要增加每个编译版本的计数并显示当前日期并以表格的形式显示。我可以使用conf.py在sphinx文档中显示版本历史记录表吗?
自动增加版本号不存在狮身人面像的固有方式。但由于conf.py是一个python文件,你可以实现一个包含在conf.py中的小函数,它从非易失性存储器(例如json文件)读取版本,输出日期表并更新非增量版本号易失性存储器。也许这样(如果json的内容是例如“[12,7,1,0]”):
# Read the version number from conf.json
fp = open('conf.json', 'r')
rev = json.load(fp) # rev = [12,7,1,0]
fp.close
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '{}.{}'.format(rev[0], rev[1]) # version = "12.7"
# The full version, including alpha/beta/rc tags.
release = '{}.{}.{}.{}'.format(*rev) # release = "12.7.1.0"
# Write the incremented version number to conf.json
fp = open ('conf.json', 'w')
rev[0] += 1
json.dump(rev, fp)
fp.close()