Alexander Thomas | b5c63ce | 2021-04-15 10:10:20 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 2 | # Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | import argparse |
| 7 | import sys |
| 8 | import utils |
| 9 | |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 10 | |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 11 | def ParseArgs(args): |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 12 | args = args[1:] |
| 13 | parser = argparse.ArgumentParser( |
| 14 | description='A script to write a custom dartdoc_options.yaml to a file') |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 15 | |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 16 | parser.add_argument( |
| 17 | '--output', '-o', type=str, required=True, help='File to write') |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 18 | |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 19 | return parser.parse_args(args) |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | def Main(argv): |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 23 | args = ParseArgs(argv) |
| 24 | # TODO(jcollins-g): switch to version numbers when github has its tags synced |
| 25 | revision = utils.GetGitRevision() |
| 26 | if revision is None: |
| 27 | revision = 'master' |
| 28 | output = '''dartdoc: |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 29 | categoryOrder: ["Core", "VM", "Web"] |
| 30 | linkToSource: |
| 31 | root: '.' |
| 32 | uriTemplate: 'https://github.com/dart-lang/sdk/blob/%s/sdk/%%f%%#L%%l%%' |
Janice Collins | 1426aff | 2021-06-29 19:31:28 +0000 | [diff] [blame] | 33 | errors: |
| 34 | # Default errors of dartdoc: |
| 35 | - duplicate-file |
| 36 | - invalid-parameter |
| 37 | - no-defining-library-found |
| 38 | - tool-error |
| 39 | - unresolved-export |
| 40 | # Warnings that are elevated to errors: |
| 41 | - ambiguous-doc-reference |
| 42 | - ambiguous-reexport |
| 43 | - broken-link |
| 44 | - category-order-gives-missing-package-name |
| 45 | - deprecated |
| 46 | - ignored-canonical-for |
| 47 | - missing-from-search-index |
| 48 | - no-canonical-found |
| 49 | - no-documentable-libraries |
| 50 | - no-library-level-docs |
| 51 | - not-implemented |
| 52 | - orphaned-file |
| 53 | - reexported-private-api-across-packages |
| 54 | # - unknown-directive # Disabled due to https://github.com/dart-lang/dartdoc/issues/2353 |
| 55 | - unknown-file |
| 56 | - unknown-macro |
| 57 | - unresolved-doc-reference |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 58 | ''' % revision |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 59 | with open(args.output, 'w') as f: |
| 60 | f.write(output) |
| 61 | return 0 |
| 62 | |
Janice Collins | 1c8f571 | 2019-02-07 18:46:31 +0000 | [diff] [blame] | 63 | |
| 64 | if __name__ == '__main__': |
Nate Bosch | 55f81f2 | 2019-08-05 20:34:31 +0000 | [diff] [blame] | 65 | sys.exit(Main(sys.argv)) |