doc.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Package genall defines entrypoints for generation tools to hook into and
  14. // share the same set of parsing, typechecking, and marker information.
  15. //
  16. // # Generators
  17. //
  18. // Each Generator knows how to register its markers into a central Registry,
  19. // and then how to generate output using a Collector and some root packages.
  20. // Each generator can be considered to be the output type of a marker, for easy
  21. // command line parsing.
  22. //
  23. // # Output and Input
  24. //
  25. // Generators output artifacts via an OutputRule. OutputRules know how to
  26. // write output for different package-associated (code) files, as well as
  27. // config files. Each OutputRule should also be considered to be the output
  28. // type as a marker, for easy command-line parsing.
  29. //
  30. // OutputRules groups together an OutputRule per generator, plus a default
  31. // output rule for any not explicitly specified.
  32. //
  33. // OutputRules are defined for stdout, file writing, and sending to /dev/null
  34. // (useful for doing "type-checking" without actually saving the results).
  35. //
  36. // InputRule defines custom input loading, but its shared across all
  37. // Generators. There's currently only a filesystem implementation.
  38. //
  39. // # Runtime and Context
  40. //
  41. // Runtime maps together Generators, and constructs "contexts" which provide
  42. // the common collector and roots, plus the output rule for that generator, and
  43. // a handle for reading files (like boilerplate headers).
  44. //
  45. // It will run all associated generators, printing errors and automatically
  46. // skipping type-checking errors (since those are commonly caused by the
  47. // partial type-checking of loader.TypeChecker).
  48. //
  49. // # Options
  50. //
  51. // The FromOptions (and associated helpers) function makes it easy to use generators
  52. // and output rules as markers that can be parsed from the command line, producing
  53. // a registry from command line args.
  54. package genall