(f)
| 115 | |
| 116 | |
| 117 | def write_file(f): |
| 118 | f.write(header) |
| 119 | |
| 120 | current_comment = [] |
| 121 | current_tags = [] |
| 122 | for line in read_file(path_from_root('src/settings.js')).splitlines(): |
| 123 | if not line: |
| 124 | current_comment = [] |
| 125 | current_tags = [] |
| 126 | if line.startswith('//'): |
| 127 | line = line[2:] |
| 128 | # Strip at most one leading space |
| 129 | if line and line[0] == ' ': |
| 130 | line = line[1:] |
| 131 | if line.startswith('[') and line.endswith(']'): |
| 132 | tag = line.strip('[') |
| 133 | tag = tag.rstrip(']') |
| 134 | if tag in all_tags: |
| 135 | current_tags.append(tag) |
| 136 | continue |
| 137 | current_comment.append(line) |
| 138 | elif line.startswith('var'): |
| 139 | # Format: |
| 140 | # var NAME = DEFAULT; |
| 141 | # Split it and strip the final ';'. |
| 142 | _, setting_name, _, setting_default = line.strip(';').split(None, 3) |
| 143 | comment = '\n'.join(current_comment).strip() |
| 144 | check_tags(setting_name, current_tags) |
| 145 | write_setting(f, setting_name, setting_default, comment, current_tags) |
| 146 | current_comment = [] |
| 147 | current_tags = [] |
| 148 | |
| 149 | f.write(deprecated_header) |
| 150 | |
| 151 | for name, desc in DEPRECATED_SETTINGS.items(): |
| 152 | f.write(f' - ``{name}``: {desc}\n') |
| 153 | |
| 154 | f.write(legacy_header) |
| 155 | |
| 156 | for name, values, *extra_fields in LEGACY_SETTINGS: |
| 157 | desc = f'Valid values: {values}' |
| 158 | if extra_fields: |
| 159 | desc = f'{extra_fields[0]} ({desc})' |
| 160 | f.write(f' - ``{name}``: {desc}\n') |
| 161 | |
| 162 | |
| 163 | def main(args): |
no test coverage detected