Changeset 7bb290c in sasmodels for doc/gentoc.py
- Timestamp:
- Dec 1, 2015 12:41:57 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 9404dd3
- Parents:
- e88bb78
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/gentoc.py
r61ba623 r7bb290c 28 28 file.write(TEMPLATE%{'label':label, 'title':title, 'bar':'*'*len(title)}) 29 29 if parent: 30 _add_subcategory( parent, category_name)30 _add_subcategory(category_name, parent) 31 31 return file 32 32 33 def _add_subcategory( file, category_name):34 file.write(" %s.rst\n"%category_name)33 def _add_subcategory(category_name, parent): 34 parent.write(" %s.rst\n"%category_name) 35 35 36 36 def _add_model(file, model_name): 37 37 file.write(" ../../model/%s.rst\n"%model_name) 38 39 def _maybe_make_category(category, models, cat_files, model_toc): 40 if category not in cat_files: 41 print >>sys.stderr, "Unexpected category %s containing"%category, models 42 title = category.capitalize()+" Functions" 43 cat_files[category] = _make_category(category, category, title, model_toc) 38 44 39 45 def generate_toc(model_files): … … 58 64 print >>sys.stderr, "Category %s contains only %s"%(k,v[0]) 59 65 60 # Generate category files 61 # Assume that top-level groups are: 62 # shape, shape-independent, structure-factor and custom 63 # Supports a two-level category structure. 66 # Generate category files for the table of contents. 67 # Initially we had "shape functions" as an additional TOC level, but we 68 # have revised it so that the individual shape categories now go at 69 # the top level. Judicious rearrangement of comments will make the 70 # "shape functions" level reappear. 71 # We are forcing shape-independent, structure-factor and custom-models 72 # to come at the end of the TOC. All other categories will come in 73 # alphabetical order before them. 64 74 65 75 if not exists(MODEL_TOC_PATH): mkdir(MODEL_TOC_PATH) 66 76 model_toc = _make_category( 67 77 'index', 'Models', 'Model Functions') 68 shape_toc = _make_category(69 'shape', 'Shapes', 'Shape Functions', model_toc)78 #shape_toc = _make_category( 79 # 'shape', 'Shapes', 'Shape Functions', model_toc) 70 80 free_toc = _make_category( 71 81 'shape-independent', 'Shape-independent', 72 'Shape-Independent Functions' , model_toc)82 'Shape-Independent Functions') 73 83 struct_toc = _make_category( 74 'structure-factor', 'Structure-factor', 'Structure Factors' , model_toc)84 'structure-factor', 'Structure-factor', 'Structure Factors') 75 85 custom_toc = _make_category( 76 'custom-models', 'Custom-models', 'Custom Models', model_toc) 77 model_toc.close() 86 'custom-models', 'Custom-models', 'Custom Models') 78 87 79 88 # remember to top level categories 80 89 cat_files = { 81 'shape':shape_toc, 90 #'shape':shape_toc, 91 'shape':model_toc, 82 92 'shape-independent':free_toc, 83 93 'structure-factor': struct_toc, … … 89 99 if ':' in k: 90 100 cat,subcat = k.split(':') 101 _maybe_make_category(cat, v, cat_files, model_toc) 91 102 cat_file = cat_files[cat] 92 103 label = "-".join((cat,subcat)) … … 98 109 sub_toc.close() 99 110 else: 100 if k not in cat_files: 101 print >>sys.stderr, "Unknown category %s containing"%cat, v 102 else: 103 cat_file = cat_files[k] 104 for model in sorted(v): 105 _add_model(cat_file, model) 111 _maybe_make_category(k, v, cat_files, model_toc) 112 cat_file = cat_files[k] 113 for model in sorted(v): 114 _add_model(cat_file, model) 115 116 #_add_subcategory('shape', model_toc) 117 _add_subcategory('shape-independent', model_toc) 118 _add_subcategory('structure-factor', model_toc) 119 _add_subcategory('custom-models', model_toc) 106 120 107 121 # Close the top-level category files 122 #model_toc.close() 108 123 for f in cat_files.values(): f.close() 109 124
Note: See TracChangeset
for help on using the changeset viewer.