2016-12-28 46 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() 
相關問題