FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow specifying order of documentation blocks · feiyunwill/daScript@bef992a · GitHub

Commit bef992a

Browse files
Allow specifying order of documentation blocks
We may want to change the predefined order (for example, to put classes before structs). Now it can be done through setting doc_block_order. It also allows for removing not needed blocks if it's the case. We could alternatively provide a map with priorities, but a priority list is more explicit and already sorted.
1 parent 3a56253 commit bef992a

1 file changed

Lines changed: 75 additions & 19 deletions

File tree

‎daslib/rst.das‎

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ require daslib/strings_boost
2121
require daslib/regex
2222
require daslib/regex_boost
2323

24+
enum DocumentBlock {
25+
Typedefs,
26+
GlobalConstants,
27+
Enumerations,
28+
Structures,
29+
StructureAnnotations,
30+
FunctionAnnotations,
31+
CallMacros,
32+
ReaderMacros,
33+
VariantMacros,
34+
TypeinfoMacros,
35+
Annotations,
36+
EnumerationAnnotations,
37+
StructureMacros,
38+
TypeMacros,
39+
Classes,
40+
Functions,
41+
}
42+
2443
let { //! Configuration constants for the RST documentation generator.
2544
log_documentation = false
2645
show_hidden_groups = false
@@ -36,6 +55,24 @@ var public {
3655
strict_struct_fields = true
3756
group_function_overloads = true
3857
property_assignment_operator = ":="
58+
doc_block_order = [
59+
DocumentBlock.Typedefs,
60+
DocumentBlock.GlobalConstants,
61+
DocumentBlock.Enumerations,
62+
DocumentBlock.Structures,
63+
DocumentBlock.StructureAnnotations,
64+
DocumentBlock.FunctionAnnotations,
65+
DocumentBlock.CallMacros,
66+
DocumentBlock.ReaderMacros,
67+
DocumentBlock.VariantMacros,
68+
DocumentBlock.TypeinfoMacros,
69+
DocumentBlock.Annotations,
70+
DocumentBlock.EnumerationAnnotations,
71+
DocumentBlock.StructureMacros,
72+
DocumentBlock.TypeMacros,
73+
DocumentBlock.Classes,
74+
DocumentBlock.Functions
75+
]
3976
}
4077

4178
var private seen_function_labels : table<string; uint>
@@ -2095,25 +2132,44 @@ def public documents(name : string; mods : array<Module?>; fname : string; var g
20952132
break
20962133
}
20972134

2098-
document_typedefs(doc_file, mods)
2099-
document_global_constants(doc_file, mods)
2100-
let wasEnums = document_enumerations(doc_file, mods)
2101-
if (hook.afterEnums != null) {
2102-
hook.afterEnums |> invoke(doc_file, wasEnums)
2103-
}
2104-
document_structures(doc_file, mods)
2105-
document_structure_annotations(doc_file, mods, hook)
2106-
document_function_annotations(doc_file, mods, hook)
2107-
document_call_macros(doc_file, mods)
2108-
document_reader_macros(doc_file, mods)
2109-
document_variant_macros(doc_file, mods)
2110-
document_typeinfo_macros(doc_file, mods)
2111-
document_annotations(doc_file, mods, hook)
2112-
document_enumeration_annotations(doc_file, mods, hook)
2113-
document_structure_macros(doc_file, mods)
2114-
document_typemacros(doc_file, mods)
2115-
document_classes(doc_file, mods)
2116-
document_functions(doc_file, mods, groups)
2135+
for (docBlock in doc_block_order) {
2136+
if (docBlock == DocumentBlock.Typedefs) {
2137+
document_typedefs(doc_file, mods)
2138+
} elif (docBlock == DocumentBlock.GlobalConstants) {
2139+
document_global_constants(doc_file, mods)
2140+
} elif (docBlock == DocumentBlock.Enumerations) {
2141+
let wasEnums = document_enumerations(doc_file, mods)
2142+
if (hook.afterEnums != null) {
2143+
hook.afterEnums |> invoke(doc_file, wasEnums)
2144+
}
2145+
} elif (docBlock == DocumentBlock.Structures) {
2146+
document_structures(doc_file, mods)
2147+
} elif (docBlock == DocumentBlock.StructureAnnotations) {
2148+
document_structure_annotations(doc_file, mods, hook)
2149+
} elif (docBlock == DocumentBlock.FunctionAnnotations) {
2150+
document_function_annotations(doc_file, mods, hook)
2151+
} elif (docBlock == DocumentBlock.CallMacros) {
2152+
document_call_macros(doc_file, mods)
2153+
} elif (docBlock == DocumentBlock.ReaderMacros) {
2154+
document_reader_macros(doc_file, mods)
2155+
} elif (docBlock == DocumentBlock.VariantMacros) {
2156+
document_variant_macros(doc_file, mods)
2157+
} elif (docBlock == DocumentBlock.TypeinfoMacros) {
2158+
document_typeinfo_macros(doc_file, mods)
2159+
} elif (docBlock == DocumentBlock.Annotations) {
2160+
document_annotations(doc_file, mods, hook)
2161+
} elif (docBlock == DocumentBlock.EnumerationAnnotations) {
2162+
document_enumeration_annotations(doc_file, mods, hook)
2163+
} elif (docBlock == DocumentBlock.StructureMacros) {
2164+
document_structure_macros(doc_file, mods)
2165+
} elif (docBlock == DocumentBlock.TypeMacros) {
2166+
document_typemacros(doc_file, mods)
2167+
} elif (docBlock == DocumentBlock.Classes) {
2168+
document_classes(doc_file, mods)
2169+
} elif (docBlock == DocumentBlock.Functions) {
2170+
document_functions(doc_file, mods, groups)
2171+
}
2172+
}
21172173
fwrite(doc_file, "\n")
21182174
fclose(doc_file)
21192175
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL