2016-12-28 40 views

回答

1

自动增加版本号不存在狮身人面像的固有方式。但由于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() 
相关问题