-
Notifications
You must be signed in to change notification settings - Fork 1
/
qa_test_doc.py
739 lines (593 loc) · 29.4 KB
/
qa_test_doc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
import sys
import os
import configparser
import re
import numpy as np
from qa_common import *
from qa_debug import *
class QATestDocVariable():
def __init__(self,name):
self._name = name
self._solution_png = []
self._error_png = []
self._error_stat = None
def add_solution_png(self,png_filename):
self._solution_png.append(png_filename)
def add_error_png(self,png_filename):
self._error_png.append(png_filename)
def set_error_stat(self,stat_filename):
self._error_stat = stat_filename
class QATestDocTimeSlice():
def __init__(self,time,time_unit):
self._time = time
self._time_unit = time_unit
self._variables = []
def add_variable(self,variable):
self._variables.append(variable)
class QATestDocObservation():
def __init__(self,location):
self._location = location
self._variables = []
def add_variable(self,variable):
self._variables.append(variable)
class QATestDocRun():
def __init__(self,run_number):
self._run_number = run_number
self._time_slices = []
self._observations = []
self._overall = []
self._filenames = {}
self._rst_filename = ''
#####time slice
self._maximum_absolute_errors = {}
self._maximum_absolute_error_times = {}
self._maximum_absolute_error_locations = {}
self._maximum_absolute_error_index = {}
self._maximum_relative_errors = {}
self._maximum_relative_error_times = {}
self._maximum_relative_error_locations = {}
self._maximum_relative_error_index = {}
self._maximum_average_absolute_errors = {}
self._maximum_average_absolute_error_times = {}
self._maximum_average_absolute_error_index = {}
self._maximum_average_relative_errors = {}
self._maximum_average_relative_error_times = {}
self._maximum_average_relative_error_index = {}
####observation point
self._maximum_absolute_errors_observation = {}
self._maximum_absolute_error_times_observation = {}
self._maximum_absolute_error_locations_observation = {}
self._maximum_absolute_error_index_observation = {}
self._maximum_relative_errors_observation = {}
self._maximum_relative_error_times_observation = {}
self._maximum_relative_error_locations_observation = {}
self._maximum_relative_error_index_observation = {}
self._maximum_average_absolute_errors_observation = {}
self._maximum_average_absolute_error_location_observation = {}
self._maximum_average_absolute_error_index_observation = {}
self._maximum_average_relative_errors_observation = {}
self._maximum_average_relative_error_location_observation = {}
self._maximum_average_relative_error_index_observation = {}
def set_input_filename(self,simulator,filename):
self._filenames[simulator] = filename
def add_time_slice(self,doc_time_slice):
self._time_slices.append(doc_time_slice)
def add_observation(self,doc_observation):
self._observations.append(doc_observation)
def add_max_absolute_error(self,variable,error):
maximum_absolute_error_all_times = self._format_documentation_values(error.maximum_absolute_error_all_times)
self._maximum_absolute_errors[variable]= maximum_absolute_error_all_times
self._maximum_absolute_error_times[variable] = error.maximum_absolute_error_time
self._maximum_absolute_error_locations[variable] = error.maximum_absolute_error_location_all_times
self._maximum_absolute_error_index[variable] = error.maximum_absolute_error_index
def add_max_relative_error(self,variable,error):
maximum_relative_error_all_times = self._format_documentation_values(error.maximum_relative_error_all_times)
self._maximum_relative_errors[variable] = maximum_relative_error_all_times
self._maximum_relative_error_times[variable] = error.maximum_relative_error_time
self._maximum_relative_error_locations[variable] = error.maximum_relative_error_location_all_times
self._maximum_relative_error_index[variable] = error.maximum_relative_error_index
def add_max_average_absolute_error(self,variable,error):
maximum_average_absolute_error = self._format_documentation_values(error.maximum_average_absolute_error)
self._maximum_average_absolute_errors[variable] = maximum_average_absolute_error
self._maximum_average_absolute_error_times[variable] = error.maximum_average_absolute_error_time
self._maximum_average_absolute_error_index[variable] = error.maximum_average_absolute_error_index
def add_max_average_relative_error(self,variable,error):
maximum_average_relative_error = self._format_documentation_values(error.maximum_average_relative_error)
self._maximum_average_relative_errors[variable] = maximum_average_relative_error
self._maximum_average_relative_error_times[variable] = error.maximum_average_relative_error_time
self._maximum_average_relative_error_index[variable] = error.maximum_average_relative_error_index
def add_max_absolute_error_observation(self,variable,error):
maximum_absolute_error_all_locations = self._format_documentation_values(error.maximum_absolute_error_all_locations)
self._maximum_absolute_errors_observation[variable]= maximum_absolute_error_all_locations
self._maximum_absolute_error_times_observation[variable] = error.maximum_absolute_error_time_all_locations
self._maximum_absolute_error_locations_observation[variable] = error.maximum_absolute_error_locations
self._maximum_absolute_error_index_observation[variable] = error.maximum_absolute_error_observation_index
def add_max_relative_error_observation(self,variable,error):
maximum_relative_error_all_locations = self._format_documentation_values(error.maximum_relative_error_all_locations)
self._maximum_relative_errors_observation[variable] = maximum_relative_error_all_locations
self._maximum_relative_error_times_observation[variable] = error.maximum_relative_error_time_all_locations
self._maximum_relative_error_locations_observation[variable] = error.maximum_relative_error_locations
self._maximum_relative_error_index_observation[variable] = error.maximum_relative_error_observation_index
def add_max_average_absolute_error_observation(self,variable,error):
maximum_average_absolute_error_observation = self._format_documentation_values(error.maximum_average_absolute_error_observation)
self._maximum_average_absolute_errors_observation[variable] = maximum_average_absolute_error_observation
self._maximum_average_absolute_error_location_observation[variable] = error.maximum_average_absolute_error_location
self._maximum_average_absolute_error_index_observation[variable] = error.maximum_average_absolute_error_observation_index
def add_max_average_relative_error_observation(self,variable,error):
maximum_average_relative_error_observation = self._format_documentation_values(error.maximum_average_relative_error_observation)
self._maximum_average_relative_errors_observation[variable] = maximum_average_relative_error_observation
self._maximum_average_relative_error_location_observation[variable] = error.maximum_average_relative_error_location
self._maximum_average_relative_error_index_observation[variable] = error.maximum_average_relative_error_observation_index
def _format_documentation_values(self,error_string):
split_array = error_string.split()
error_float = float(split_array[0])
truncated_error = format_floating_number(error_float)
try:
new_error_string = truncated_error + ' ' + split_array[1]
except:
new_error_string = truncated_error
return new_error_string
class QATestDoc(object):
def __init__(self,doc_dir,local_path):
debug_push('QATestDoc init')
self._doc_dir = doc_dir
self._local_path = local_path
self._title = ''
self._template = ''
self._filename_root = ''
self._simulators = []
self._runs = []
debug_pop()
def set_title(self,title):
debug_push('QATestDoc set_title')
self._title = title
self._filename_root = self._title.lower().replace(" ","_")
debug_pop()
def set_template(self,template):
debug_push('QATestDoc set_template')
self._template = template
debug_pop()
def add_simulator(self,simulator):
debug_push('QATestDoc add_simulator')
self._simulators.append(simulator)
debug_pop()
def add_run(self,run):
debug_push('QATestDoc add_comparison')
self._runs.append(run)
debug_pop()
def write(self):
f = open(self._filename_root+'_doc.rst','w')
f.write("""
.. _{0}:
{1}
{0}
{1}
:ref:`{2}-results summary`
:ref:`{2}-description`
:ref:`{2}-detailed results`
:ref:`{2}-input files`
""".format(self._title,'*'*len(self._title),self._filename_root))
f.write("""
.. _{}-results summary:
Results Summary
===============
""".format(self._filename_root))
for run in self._runs:
if len(run._time_slices)==1 and run._time_slices[0]._time=='steady state':
f.write('\n')
scenario_string = 'Scenario {} - Time Slice'.format(run._run_number)
f.write("{}\n".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
variable_num = 0
if run._maximum_absolute_error_index:
for variable in run._time_slices[0]._variables:
variable_string = variable._name
f.write("\n")
f.write("Variable: {}".format(variable_string))
f.write("""
.. list-table::
:widths: 50 40 40
:header-rows: 1
* -
- Value
- Location
* - :ref:`Maximum Absolute Error <{}_{}_{}_figure{}>`
- {}
- {}
* - :ref:`Maximum Relative Error <{}_{}_{}_figure{}>`
- {}
- {}
* - :ref:`Maximum Average Absolute Error <{}_{}_{}_figure{}>`
- {}
-
* - :ref:`Maximum Average Relative Error <{}_{}_{}_figure{}>`
- {}
-
""".format(self._filename_root,run._run_number,variable_string,
run._maximum_absolute_error_index[variable_string],
run._maximum_absolute_errors[variable_string],
run._maximum_absolute_error_locations[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_relative_error_index[variable_string],
run._maximum_relative_errors[variable_string],
run._maximum_relative_error_locations[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_absolute_error_index[variable_string],
run._maximum_average_absolute_errors[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_relative_error_index[variable_string],
run._maximum_average_relative_errors[variable_string]))
if run._maximum_absolute_error_index_observation:
scenario_string = 'Scenario {} - Observation Point'.format(run._run_number)
f.write("""
{}\n""".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
for variable in run._observations[0]._variables:
variable_string = variable._name
f.write("\n")
f.write("Variable: {}".format(variable_string))
f.write("""
.. list-table::
:widths: 40 25 25 25
:header-rows: 1
* -
- Value
- Time
- Location
* - :ref:`Maximum Absolute Error <{}_{}_{}_observation_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Relative Error <{}_{}_{}_observation_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Average Absolute Error <{}_{}_{}_observation_figure{}>`
- {}
-
- {}
* - :ref:`Maximum Average Relative Error <{}_{}_{}_observation_figure{}>`
- {}
-
- {}
""".format(self._filename_root,run._run_number,variable_string,
run._maximum_absolute_error_index_observation[variable_string],
run._maximum_absolute_errors_observation[variable_string],
run._maximum_absolute_error_times_observation[variable_string],
run._maximum_absolute_error_locations_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_relative_error_index_observation[variable_string],
run._maximum_relative_errors_observation[variable_string],
run._maximum_relative_error_times_observation[variable_string],
run._maximum_relative_error_locations_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_absolute_error_index_observation[variable_string],
run._maximum_average_absolute_errors_observation[variable_string],
run._maximum_average_absolute_error_location_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_relative_error_index_observation[variable_string],
run._maximum_average_relative_errors_observation[variable_string],
run._maximum_average_relative_error_location_observation[variable_string]))
else:
f.write('\n')
scenario_string = 'Scenario {} - Time Slice'.format(run._run_number)
f.write("{}\n".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
variable_num = 0
if run._maximum_absolute_error_index:
for variable in run._time_slices[0]._variables:
variable_string = variable._name
f.write("\n")
f.write("Variable: {}".format(variable_string))
f.write("""
.. list-table::
:widths: 40 25 25 25
:header-rows: 1
* -
- Value
- Time
- Location
* - :ref:`Maximum Absolute Error <{}_{}_{}_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Relative Error <{}_{}_{}_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Average Absolute Error <{}_{}_{}_figure{}>`
- {}
- {}
-
* - :ref:`Maximum Average Relative Error <{}_{}_{}_figure{}>`
- {}
- {}
-
""".format(self._filename_root,run._run_number,variable_string,
run._maximum_absolute_error_index[variable_string],
run._maximum_absolute_errors[variable_string],
run._maximum_absolute_error_times[variable_string],
run._maximum_absolute_error_locations[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_relative_error_index[variable_string],
run._maximum_relative_errors[variable_string],
run._maximum_relative_error_times[variable_string],
run._maximum_relative_error_locations[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_absolute_error_index[variable_string],
run._maximum_average_absolute_errors[variable_string],
run._maximum_average_absolute_error_times[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_relative_error_index[variable_string],
run._maximum_average_relative_errors[variable_string],
run._maximum_average_relative_error_times[variable_string]))
if run._maximum_absolute_error_index_observation:
scenario_string = 'Scenario {} - Observation Point'.format(run._run_number)
f.write("""
{}\n""".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
for variable in run._observations[0]._variables:
variable_string = variable._name
f.write("\n")
f.write("Variable: {}".format(variable_string))
f.write("""
.. list-table::
:widths: 40 25 25 25
:header-rows: 1
* -
- Value
- Time
- Location
* - :ref:`Maximum Absolute Error <{}_{}_{}_observation_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Relative Error <{}_{}_{}_observation_figure{}>`
- {}
- {}
- {}
* - :ref:`Maximum Average Absolute Error <{}_{}_{}_observation_figure{}>`
- {}
-
- {}
* - :ref:`Maximum Average Relative Error <{}_{}_{}_observation_figure{}>`
- {}
-
- {}
""".format(self._filename_root,run._run_number,variable_string,
run._maximum_absolute_error_index_observation[variable_string],
run._maximum_absolute_errors_observation[variable_string],
run._maximum_absolute_error_times_observation[variable_string],
run._maximum_absolute_error_locations_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_relative_error_index_observation[variable_string],
run._maximum_relative_errors_observation[variable_string],
run._maximum_relative_error_times_observation[variable_string],
run._maximum_relative_error_locations_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_absolute_error_index_observation[variable_string],
run._maximum_average_absolute_errors_observation[variable_string],
run._maximum_average_absolute_error_location_observation[variable_string],
self._filename_root,run._run_number,variable_string,
run._maximum_average_relative_error_index_observation[variable_string],
run._maximum_average_relative_errors_observation[variable_string],
run._maximum_average_relative_error_location_observation[variable_string]))
description_file = '{}/{}.description'.format(self._doc_dir,self._template) ##make so this is try--> don't need it ###written in markup --> description of problem description_template... what if don't want description etc...
try:
with open(description_file,'r') as file:
description_text = file.readlines()
except:
description_text = ["TO BE ADDED LATER"]
f.write("""
.. _{}-description:
The Problem Description
=======================
""".format(self._filename_root))
for i in range(len(description_text)):
if re.match('.*\.\. figure:: (?!/).*',description_text[i]): #does not start with /
split_text = description_text[i].split()
relative_path = split_text[-1]
path = '/'+self._doc_dir+'/'+relative_path
split_text[-1] = path
description_text[i] = " ".join(split_text) +'\n'
f.write('{}'.format(description_text[i]))
f.write("""
.. _{}-detailed results:
Detailed Results
================
""".format(self._filename_root))
width_percent = 60
for run in self._runs:
scenario_string = 'Scenario {} - Time Slice'.format(run._run_number)
f.write("{}\n".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
f.write("\n")
simulators = self._simulators
n = 0
for time_slice in run._time_slices:
time_string = '{} {}'.format(time_slice._time,
time_slice._time_unit)
for variable in time_slice._variables:
variable_string = variable._name
f.write("Comparison of {} at {} for {}: {}".format(
variable_string,time_string,scenario_string,
simulators[0]))
for i in range(1,len(simulators)):
f.write(" vs {}\n".format(simulators[i]))
f.write("\n")
# absolute here make it relative to the top source dir
# in the sphinx repo (usually: sphinx/doc/source/.)
f.write(".. literalinclude:: /{}/{}\n\n".format(
self._doc_dir,
variable._error_stat))
f.write(".. _{}_{}_{}_figure{}:\n".format(self._filename_root,
run._run_number,variable_string,n))
f.write("\n")
f.write(".. figure:: /{}/{}\n :width: {} %\n\n".format(
self._doc_dir,variable._solution_png[0],width_percent))
if variable._error_png:
f.write(".. figure:: /{}/{}\n :width: {} %\n\n".format(
self._doc_dir,variable._error_png[0],width_percent))
n += 1
if len(run._observations) > 0:
scenario_string = 'Scenario {} - Observation Point'.format(run._run_number)
f.write("{}\n".format(scenario_string))
f.write("{}\n".format('-'*len(scenario_string)))
k = 0
for observation in run._observations:
observation_string = '{}'.format(observation._location)
for variable in observation._variables:
variable_string = variable._name
f.write("Comparison of {} at {} for {}: {}".format(
variable_string,observation_string,scenario_string,
simulators[0]))
for i in range(1,len(simulators)):
f.write(" vs {}\n".format(simulators[i]))
f.write("\n")
f.write(".. _{}_{}_{}_observation_figure{}:\n".format(self._filename_root,
run._run_number,variable_string,k))
f.write("\n")
f.write(".. literalinclude:: /{}/{}\n\n".format(
self._doc_dir,variable._error_stat))
f.write(".. figure:: /{}/{}\n :width: {} %\n\n".format(
self._doc_dir,
variable._solution_png[0],width_percent))
if variable._error_png:
f.write(".. figure:: /{}/{}\n :width: {} %\n\n".format(
self._doc_dir,
variable._error_png[0],width_percent))
k += 1
f.write("""
.. _{}-input files:
Input Files
===========
""".format(self._filename_root))
for run in self._runs:
scenario_string = 'Scenario {}'.format(run._run_number)
f.write("""
{}
{}
""".format(scenario_string,'-'*len(scenario_string)))
for simulator in self._simulators:
f.write("""
The {} input file can be downloaded
:download:`here </{}/{}>`
""".format(simulator,self._doc_dir,run._filenames[simulator]))
f.close()
class QATestDocIndex(object):
def __init__(self,testlog,_doc_dir):
self.testlog = testlog
if _doc_dir == None:
self._doc_dir = '../docs'
else:
self._doc_dir = _doc_dir
if not os.path.isdir(self._doc_dir):
print_err_msg('Document Directory Path: {} does not exist'.format(self._doc_dir))
def write_index(self):
file_dict = self.testlog.read_contents()
regression_dict = self.testlog.read_contents(regression=True)
directory_titles = self.testlog.get_directory_titles()
f = open('{}/index.rst'.format(self._doc_dir),'w')
intro = """
***************************
QA Test Suite Documentation
***************************
.. toctree::
:maxdepth: 2
"""
f.write(intro)
for folder_path in file_dict.keys():
folder = folder_path.strip().split('/')[-1]
f.write("""
intro_{}.rst
""".format(folder))
#####must add toctree label back in or else will not work
f.write("""
----
.. toctree::
:maxdepth: 2
""")
for folder_path in regression_dict.keys():
folder = folder_path.strip().split('/')[-1]
f.write("""
intro_{}.rst
""".format(folder))
file_dict.update(regression_dict)
toctree_intro = """
.. toctree::
:hidden:
"""
f.write(toctree_intro)
for folder_path,tests in file_dict.items():
folder = folder_path.strip().split('/')[-1]
for i in range(len(tests)):
test=tests[i].lower().replace(" ","_")
toctree="""
include_toctree_{}_{}.rst""".format(folder,test)
f.write(toctree)
f.close()
self.write_toctree(file_dict)
self.write_introfiles(file_dict,directory_titles)
def write_toctree(self,file_dict):
for folder_path,tests in file_dict.items():
folder = folder_path.strip().split('/')[-1]
for i in range(len(tests)):
test=tests[i].lower().replace(" ","_")
filename = '{}/include_toctree_{}_{}.rst'.format(self._doc_dir,folder,test)
f = open(filename, 'w')
toctree = """
.. include:: //{}/{}_doc.rst
""".format(folder_path,test)
f.write(toctree)
f.close()
def write_introfiles(self, file_dict,directory_titles):
for folder_path, test in file_dict.items():
folder = folder_path.strip().split('/')[-1]
if folder_path in directory_titles.keys():
title = directory_titles[folder_path]
else:
title = folder
filename = '{}/intro_{}.rst'.format(self._doc_dir,folder)
intro = """
.. {}-qa-tests:
{}
{}
""".format(folder,title,'='*(len(title)+9))
intro_links = [None]*len(test)
if len(test) == 1:
intro_links[0] = """
* :ref:`{}`
""".format(test[0])
else:
for i in range(len(test)):
intro_links[i] = """
{}
{}
* :ref:`{}`
""".format(test[i],'-'*len(test[i]),test[i])
f = open(filename, 'w')
f.write(intro)
for i in range(len(test)):
f.write(intro_links[i])
description_file = "{}/{}.description".format(folder_path,folder)
try:
with open(description_file,'r') as file:
description_text = file.readlines()
except:
description_text = [" "]
f.write("\n")
for i in range(len(description_text)):
if re.match('.*\.\. figure:: (?!/).*',description_text[i]): #does not start with /
split_text = description_text[i].split()
relative_path = split_text[-1]
path = '/'+folder_path+'/'+relative_path
split_text[-1] = path
description_text[i] = " ".join(split_text) +'\n'
f.write('{}'.format(description_text[i]))
f.write("\n")
# f.write("""
#
#{}
#
# """.format(description_text))
f.close()