command-line-interface-pages / v2-tooling

Tools for handling v2.*.* syntax
6 stars 3 forks source link

Allow define any custom TlDr convertible placeholders #48

Closed EmilyGraceSeville7cf closed 1 year ago

EmilyGraceSeville7cf commented 1 year ago

closes #41

image

EmilyGraceSeville7cf commented 1 year ago

@kbdharun, can you check this file? Is it user-friendly to edit in your opinion? It contains custom placeholders those converter will recognize.

To get intellisence in it install YAML Red Hat VS Code extension.

Here is example how to add a new TlDr placeholder:

- in-placeholder: bla
  out-type: string

As a result {{bla}} will be treated as a string and converted to {string bla}. Note that plural nouns (blas, bla_values, bla(s), bla{1,2,3,...}) automatically being supported. By default plural nouns require _values suffix, but it can be changed to _names (bla_names). More useful application of this is defining placeholder for x position:

- in-placeholder: x_position
  out-type: int
  out-description: x

Given this TlDr placeholder: {{x_position}} we get {int x}. To mention several positions use {{x_positions}}, {{x_position_values}},{{x_position(s)}}, or {{x_position{1,2,3}}} which results in {int* x}. (s) like brace expansion are suffixes available everywhere to make placeholders accept several arguments. This happens because before placeholder expansion all (s) and brace expansions are expanded.

Contractions are also supported via in-index key: it's possible to allow use abbreviations like {{arg}} instead of {{argument}}.

implementation is here