Generate the Antora navigation sidebar for the refpages. Assumes there is a page for everything in the api module dictionaries. Extensions (KHR, EXT, etc.) are currently skipped navfile - output filename to generate
(navfile)
| 852 | |
| 853 | |
| 854 | def genAntoraNav(navfile): |
| 855 | """Generate the Antora navigation sidebar for the refpages. |
| 856 | |
| 857 | Assumes there is a page for everything in the api module dictionaries. |
| 858 | Extensions (KHR, EXT, etc.) are currently skipped |
| 859 | |
| 860 | navfile - output filename to generate |
| 861 | """ |
| 862 | |
| 863 | fp = open(navfile, 'w', encoding='utf-8') |
| 864 | |
| 865 | head = '\n'.join(( |
| 866 | '// Generated by genRef.py:genAntoraNav() from the setup_refpages_antora', |
| 867 | '// Makefile target.', |
| 868 | '// To make changes, modify that script.', |
| 869 | '', |
| 870 | ':chapters:', |
| 871 | '', |
| 872 | f'* xref:index.adoc[{apiName} API Reference Pages]', |
| 873 | )) |
| 874 | |
| 875 | printCopyrightSourceComments(fp) |
| 876 | print(head, file=fp) |
| 877 | |
| 878 | #@ Temporary workaround - remap XML category to match refpage 'type' |
| 879 | # We do not need the refpage 'type' for API types, since the API map is a |
| 880 | # canonical source of that information. |
| 881 | remapXMLCategory = { |
| 882 | 'basetype' : 'basetypes', |
| 883 | 'define' : 'defines', |
| 884 | 'consts' : 'enums', |
| 885 | 'group' : 'enums', |
| 886 | 'bitmask' : 'flags', |
| 887 | 'funcpointer' : 'funcpointers', |
| 888 | 'handle' : 'handles', |
| 889 | 'struct' : 'structs', |
| 890 | 'union' : 'structs', |
| 891 | } |
| 892 | |
| 893 | # Sweep over generated pages |
| 894 | #@@@ refPageTail cannot determine specification page containing |
| 895 | # [SPIR-V terms, VK_NO_PROTOTYPES, RuntimeSpirv, etc.] |
| 896 | for (name, pi) in sorted(pages.items()): |
| 897 | # Classify each page into tables of either an API or other type |
| 898 | # depending on its 'type'. |
| 899 | # The set of names of pages for each refpage type is built here. |
| 900 | if pi.type not in refpageType: |
| 901 | logErr(f'genAntoraNav: unknown refpage type {pi.type}') |
| 902 | refpageType[pi.type].pagenames.add(name) |
| 903 | |
| 904 | # Check that the refpage 'type' attribute matches the type from |
| 905 | # the API map, if this is an API |
| 906 | if name in api.typeCategory: |
| 907 | category = api.typeCategory[name] |
| 908 | |
| 909 | if category in remapXMLCategory: |
| 910 | category = remapXMLCategory[category] |
| 911 |
no test coverage detected