Extract reference pages from a spec asciidoc source file. - specFile - filename to extract from - baseDir - output directory to generate page in - aliasFrom - map from refpage name to a set of its aliases
(specFile, baseDir, aliasFrom)
| 776 | |
| 777 | |
| 778 | def genRef(specFile, baseDir, aliasFrom): |
| 779 | """Extract reference pages from a spec asciidoc source file. |
| 780 | |
| 781 | - specFile - filename to extract from |
| 782 | - baseDir - output directory to generate page in |
| 783 | - aliasFrom - map from refpage name to a set of its aliases""" |
| 784 | |
| 785 | # We do not care the newline format used here. |
| 786 | file, _ = loadFile(specFile) |
| 787 | if file is None: |
| 788 | return |
| 789 | |
| 790 | # Save the path to this file for later use in rewriting relative includes |
| 791 | specDir = os.path.dirname(os.path.abspath(specFile)) |
| 792 | |
| 793 | refpageMap = findRefs(file, specFile, aliasFrom) |
| 794 | logDiag(f'{specFile}: found {len(refpageMap)} potential pages') |
| 795 | |
| 796 | # Fix up references in refpageMap |
| 797 | fixupRefs(refpageMap, specFile, file) |
| 798 | |
| 799 | # Create each page, if possible |
| 800 | pages = {} |
| 801 | |
| 802 | for (name, pi) in sorted(refpageMap.items()): |
| 803 | # Only generate the page if it is in the requested build |
| 804 | # 'freeform' pages are always generated |
| 805 | # 'feature' pages (core versions & extensions) are generated if they are in |
| 806 | # the requested feature list |
| 807 | # All other pages (APIs) are generated if they are in the API map for |
| 808 | # the build. |
| 809 | if pi.type in refpageType: |
| 810 | isapi = refpageType[pi.type].isapi |
| 811 | |
| 812 | if isapi: |
| 813 | if name not in api.typeCategory: |
| 814 | # Also check aliases of name - api.nonexistent is the same |
| 815 | # mapping used to rewrite *link: macros in this build. |
| 816 | if name not in api.nonexistent: |
| 817 | logWarn(f'genRef: NOT generating feature page {name} - API not in this build') |
| 818 | continue |
| 819 | else: |
| 820 | logWarn(f'genRef: generating feature page {name} because its alias {api.nonexistent[name]} exists') |
| 821 | else: |
| 822 | # The only non-API type which can be checked is a feature refpage |
| 823 | if pi.type == 'feature': |
| 824 | if name not in api.features: |
| 825 | logWarn(f'genRef: NOT generating feature page {name} - feature not in this build') |
| 826 | continue |
| 827 | |
| 828 | printPageInfo(pi, file) |
| 829 | |
| 830 | if pi.Warning: |
| 831 | logWarn(f'genRef: {pi.name}: {pi.Warning}') |
| 832 | |
| 833 | if pi.extractPage: |
| 834 | emitPage(baseDir, specDir, pi, file) |
| 835 | elif pi.type == 'enums': |
no test coverage detected