@@ -45,86 +45,46 @@ def get_target(self, tid):
45
45
self .state .document .note_explicit_target (target )
46
46
return target
47
47
48
- def species_summary_table (self , species ):
49
- table = nodes .table ()
50
- tgroup = nodes .tgroup (cols = 2 )
51
- colspec = nodes .colspec (colwidth = 1 )
52
- tgroup .append (colspec )
53
- colspec = nodes .colspec (colwidth = 1 )
54
- tgroup .append (colspec )
55
- colspec = nodes .colspec (colwidth = 1 )
56
- tgroup .append (colspec )
57
-
58
- table += tgroup
59
-
60
- data = [
61
- ("id" , species .id , "" ),
62
- ("name" , species .name , "" ),
63
- ("generation_time" , species .generation_time ,
64
- "TODO: Notes for generation_time" ),
65
- ("population_size" , species .population_size ,
66
- "TODO: Notes for population_size" ),
67
- ]
68
-
69
- rows = []
70
- for row_data in data :
71
- row = nodes .row ()
72
- rows .append (row )
73
- for entry_data in row_data :
74
- entry = nodes .entry ()
75
- entry += nodes .paragraph (text = entry_data )
76
- row += entry
48
+ def make_field_list (self , data ):
77
49
78
- tbody = nodes .tbody ()
79
- tbody .extend (rows )
80
- tgroup += tbody
50
+ field_list = nodes .field_list ()
51
+ for name , text , citation in data :
52
+ field = nodes .field ()
53
+ field_name = nodes .field_name (text = name )
54
+ field_body = nodes .field_body ()
55
+ para = nodes .paragraph (text = text )
81
56
82
- return table
57
+ if citation is not None :
58
+ text = f" ({ citation .author } , { citation .year } )"
59
+ para += nodes .reference (
60
+ internal = False , refuri = citation .doi , text = text )
83
61
84
- def model_table (self , model ):
85
- table = nodes .table ()
86
- tgroup = nodes .tgroup (cols = 2 )
62
+ field_body += para
63
+ field += field_name
64
+ field += field_body
65
+ field_list += field
87
66
88
- colspec = nodes .colspec (colwidth = 1 )
89
- tgroup .append (colspec )
90
- colspec = nodes .colspec (colwidth = 1 )
91
- tgroup .append (colspec )
67
+ return field_list
92
68
93
- table += tgroup
94
-
95
- rows = []
96
- row = nodes .row ()
97
- rows .append (row )
98
- entry = nodes .entry ()
99
- entry += nodes .paragraph (text = "ID" )
100
- row += entry
101
- entry = nodes .entry ()
102
- entry += nodes .paragraph (text = model .id )
103
- row += entry
104
-
105
- row = nodes .row ()
106
- rows .append (row )
107
- entry = nodes .entry ()
108
- entry += nodes .paragraph (text = "Description" )
109
- row += entry
110
- entry = nodes .entry ()
111
- entry += nodes .paragraph (text = model .description )
112
- row += entry
113
-
114
- row = nodes .row ()
115
- rows .append (row )
116
- entry = nodes .entry ()
117
- entry += nodes .paragraph (text = "Num populations" )
118
- row += entry
119
- entry = nodes .entry ()
120
- entry += nodes .paragraph (text = model .num_populations )
121
- row += entry
122
-
123
- tbody = nodes .tbody ()
124
- tbody .extend (rows )
125
- tgroup += tbody
69
+ def species_summary (self , species ):
70
+ data = [
71
+ ("ID" , species .id , None ),
72
+ ("Name" , species .name , None ),
73
+ ("Common name" , species .common_name , None ),
74
+ ("Generation time" , species .generation_time ,
75
+ species .generation_time_citations [0 ]),
76
+ ("Population size" , species .population_size ,
77
+ species .population_size_citations [0 ]),
78
+ ]
79
+ return self .make_field_list (data )
126
80
127
- return table
81
+ def model_summary (self , model ):
82
+ data = [
83
+ ("ID" , model .id , None ),
84
+ ("Description" , model .description , None ),
85
+ ("Num populations" , model .num_populations , None ),
86
+ ]
87
+ return self .make_field_list (data )
128
88
129
89
def citation_list (self , citable ):
130
90
bullet_list = nodes .bullet_list ()
@@ -411,7 +371,7 @@ def model_section(self, species, model):
411
371
section += nodes .title (text = model .description )
412
372
section += nodes .paragraph (text = model .long_description )
413
373
section += nodes .rubric (text = "Details" )
414
- section += self .model_table (model )
374
+ section += self .model_summary (model )
415
375
section += nodes .rubric (text = "Populations" )
416
376
section += self .population_table (model )
417
377
section += nodes .rubric (text = "Citations" )
@@ -427,7 +387,7 @@ def run(self):
427
387
species_target = self .get_target (sid )
428
388
section = nodes .section (ids = [sid ], names = [sid ])
429
389
section += nodes .title (text = species .name )
430
- section += self .species_summary_table (species )
390
+ section += self .species_summary (species )
431
391
432
392
genome_section = nodes .section (ids = [f"sec_catalog_{ species .id } _genome" ])
433
393
genome_section += nodes .title (text = "Genome" )
0 commit comments