- Timestamp:
- Mar 30, 2019 1:59:45 AM (6 years ago)
- Branches:
- master
- Children:
- a42b091
- Parents:
- 663d2a8
- Location:
- doc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/conf.py
r30b60d2 rc1e44e5 36 36 #'only_directives', 37 37 #'matplotlib.sphinxext.mathmpl', 38 'matplotlib.sphinxext.only_directives',38 #'matplotlib.sphinxext.only_directives', 39 39 'matplotlib.sphinxext.plot_directive', 40 40 'dollarmath', -
doc/genmodel.py
rb866abf rc1e44e5 7 7 import matplotlib.pyplot as plt 8 8 sys.path.insert(0, os.path.abspath('..')) 9 import sasmodels 9 10 from sasmodels import generate, core 10 11 from sasmodels.direct_model import DirectModel, call_profile … … 127 128 #print("figure saved in",path) 128 129 130 def copy_if_newer(src, dst): 131 from os.path import dirname, exists, getmtime 132 import shutil 133 if not exists(dst): 134 path = dirname(dst) 135 if not exists(path): 136 os.makedirs(path) 137 shutil.copy2(src, dst) 138 elif getmtime(src) > getmtime(dst): 139 shutil.copy2(src, dst) 140 141 def link_sources(model_info): 142 from os.path import basename, dirname, realpath, join as joinpath 143 144 # List source files in reverse order of dependency. 145 model_file = basename(model_info.filename) 146 sources = list(reversed(model_info.source + [model_file])) 147 148 # Copy files to src dir under models directory. Need to do this 149 # because sphinx can't link to an absolute path. 150 root = dirname(dirname(realpath(__file__))) 151 src = joinpath(root, "sasmodels", "models") 152 dst = joinpath(root, "doc", "model", "src") 153 for path in sources: 154 copy_if_newer(joinpath(src, path), joinpath(dst, path)) 155 156 # Link to local copy of the files 157 downloads = [":download:`%s <src/%s>`"%(path, path) for path in sources] 158 159 # Link to github repo (either the tagged sasmodels version or master) 160 url = "https://github.com/SasView/sasmodels/blob/v%s"%sasmodels.__version__ 161 #url = "https://github.com/SasView/sasmodels/blob/master"%sasmodels.__version__ 162 links = ["`%s <%s/sasmodels/models/%s>`_"%(path, url, path) for path in sources] 163 164 sep = u"\n\\ \u25E6 \\ " # bullet 165 body = "\n**Source**\n" 166 #body += "\n\\ " + sep.join(links) + "\n\n" 167 body += "\n\\ " + sep.join(downloads) + "\n\n" 168 return body 169 129 170 def gen_docs(model_info): 130 171 # type: (ModelInfo) -> None … … 150 191 match = re.search(pattern, docstr.upper()) 151 192 193 sources = link_sources(model_info) 194 195 insertion = captionstr + sources 196 152 197 if match: 153 198 docstr1 = docstr[:match.start()] 154 199 docstr2 = docstr[match.start():] 155 docstr = docstr1 + captionstr+ docstr2200 docstr = docstr1 + insertion + docstr2 156 201 else: 157 202 print('------------------------------------------------------------------') 158 203 print('References NOT FOUND for model: ', model_info.id) 159 204 print('------------------------------------------------------------------') 160 docstr += captionstr205 docstr += insertion 161 206 162 207 open(sys.argv[2],'w').write(docstr)
Note: See TracChangeset
for help on using the changeset viewer.