Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrate-1.0.md 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Migrating 0.x to 1.x
  2. ## Parser
  3. 0.x can be mostly translated into 1.x one way or another. The idea behind the new config structure is to handle only the most common cases, and provide the fallback for alternative implementation.
  4. ### `dotted_names: boolean`
  5. > By default dotted names like `name.subname.subsubname` will be expanded into nested sections, this can be prevented by passing opts.dotted_names = false.
  6. **Removed** This feature is removed but still can be done on top of the `parse()` output. Please post a request or contribute a PR if you need it.
  7. ### `trim: boolean`
  8. > Set this to false to avoid the default of trimming whitespace at the start and end of each line.
  9. In the new parser all original spacing is kept along with comment lines in `.source`. Description lines are joined together depending on `spacing` option
  10. **New option:**
  11. - `spacing: "compact"` lines concatenated with a single space and no line breaks
  12. - `spacing: "preserve"` keeps line breaks and space around as is. Indentation space counts from `*` delimiter or from the start of the line if the delimiter is omitted
  13. - `spacing: (lines: Line[]) => string` completely freeform joining strategy, since all original spacing can be accessed, there is no limit to how this can be implemented. See [primitives.ts](./src/primitives.ts) and [spacer.ts](./src/parser/spacer.ts)
  14. ### `join: string | number | boolean`
  15. > If the following lines of a multiline comment do not start with a star, `join` will have the following effect on tag source (and description) when joining the lines together:
  16. >
  17. > - If a string, use that string in place of the leading whitespace (and avoid newlines).
  18. > - If a non-zero number (e.g., 1), do no trimming and avoid newlines.
  19. > - If undefined, false, or 0, use the default behavior of not trimming but adding a newline.
  20. > - Otherwise (e.g., if join is true), replace any leading whitespace with a single space and avoid newlines.
  21. >
  22. > Note that if a multi-line comment has lines that start with a star, these will be appended with initial whitespace as is and with newlines regardless of the join setting.
  23. See the `spacing` option above, all the variations can be fine-tunned with `spacing: (lines: Line[]) => string`
  24. ### `fence: string | RegExp | ((source: string) => boolean)`
  25. > Set to a string or regular expression to toggle state upon finding an odd number of matches within a line. Defaults to ```.
  26. >
  27. > If set to a function, it should return true to toggle fenced state; upon returning true the first time, this will prevent subsequent lines from being interpreted as starting a new jsdoc tag until such time as the function returns true again to indicate that the state has toggled back.
  28. This is mostly kept the same
  29. **New optoins:**
  30. - ```` fence: '```' ```` same as 0.x
  31. - `fencer: (source: string) => boolean` same as 0.x, see [parser/block-parser.ts](./src/parser/block-parser.ts)
  32. ### `parsers: Parser[]`
  33. > In case you need to parse tags in different way you can pass opts.parsers = [parser1, ..., parserN], where each parser is function name(str:String, data:Object):{source:String, data:Object}.
  34. > ...
  35. **New options:**
  36. - `tokenizers: []Tokenizer` is a list of functions extracting the `tag`, `type`, `name` and `description` tokens from this string. See [parser/spec-parser.ts](./src/parser/spec-parser.ts) and [primitives.ts](./src/primitives.ts)
  37. Default tokenizers chain is
  38. ```js
  39. [
  40. tagTokenizer(),
  41. typeTokenizer(),
  42. nameTokenizer(),
  43. descriptionTokenizer(getSpacer(spacing)),
  44. ]
  45. ```
  46. where
  47. ```ts
  48. type Tokenizer = (spec: Spec) => Spec
  49. interface Spec {
  50. tag: string;
  51. name: string;
  52. default?: string;
  53. type: string;
  54. optional: boolean;
  55. description: string;
  56. problems: Problem[];
  57. source: Line[];
  58. }
  59. ```
  60. chain starts with blank `Spec` and each tokenizer fulfills a piece using `.source` input
  61. ## Stringifier
  62. > One may also convert comment-parser JSON structures back into strings using the stringify method (stringify(o: (object|Array) [, opts: object]): string).
  63. > ...
  64. Stringifier config follows the same strategy – a couple of common cases, and freeform formatter as a fallback
  65. **New Options:**
  66. - `format: "none"` re-assembles the source with original spacing and delimiters preserved
  67. - `format: "align"` aligns tag, name, type, and descriptions into fixed-width columns
  68. - `format: (tokens: Tokens) => string[]` do what you like, resulting lines will be concatenated into the output. Despite the simple interface, this can be turned into a complex stateful formatter, see `"align"` implementation in [transforms/align.ts](./src/transforms/align.ts)
  69. ## Stream
  70. Work in progress