Parse platform information from arguments Arguments is a comma-separated string of platforms. A platform may be prefixed with "not " to indicate that a feature is not available. Example:: .. availability:: Windows, Linux >= 4.2, not WASI Arguments like
(self)
| 80 | return [cnode] |
| 81 | |
| 82 | def parse_platforms(self) -> dict[str, str | bool]: |
| 83 | """Parse platform information from arguments |
| 84 | |
| 85 | Arguments is a comma-separated string of platforms. A platform may |
| 86 | be prefixed with "not " to indicate that a feature is not available. |
| 87 | |
| 88 | Example:: |
| 89 | |
| 90 | .. availability:: Windows, Linux >= 4.2, not WASI |
| 91 | |
| 92 | Arguments like "Linux >= 3.17 with glibc >= 2.27" are currently not |
| 93 | parsed into separate tokens. |
| 94 | """ |
| 95 | platforms = {} |
| 96 | for arg in self.arguments[0].rstrip(".").split(","): |
| 97 | arg = arg.strip() |
| 98 | platform, _, version = arg.partition(" >= ") |
| 99 | if platform.startswith("not "): |
| 100 | version = False |
| 101 | platform = platform.removeprefix("not ") |
| 102 | elif not version: |
| 103 | version = True |
| 104 | platforms[platform] = version |
| 105 | |
| 106 | if unknown := set(platforms).difference(KNOWN_PLATFORMS): |
| 107 | logger.warning( |
| 108 | "Unknown platform%s or syntax '%s' in '.. availability:: %s', " |
| 109 | "see %s:KNOWN_PLATFORMS for a set of known platforms.", |
| 110 | "s" if len(platforms) != 1 else "", |
| 111 | " ".join(sorted(unknown)), |
| 112 | self.arguments[0], |
| 113 | __file__, |
| 114 | ) |
| 115 | |
| 116 | return platforms |
| 117 | |
| 118 | |
| 119 | def setup(app: Sphinx) -> ExtensionMetadata: |
no test coverage detected