Add fixes for manual (#2391)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Benjamin Wuethrich · committed by GitHub · parent a87dca3 · Browse files · 1 file·+57 added−46 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+57 added−46 removed
- other:+57 added−46 removed
Provenance
- Commit
e066172- Tree
69d95ce- Author
Benjamin Wuethrich <benjamin@koho.ca>- Committer
GitHub <noreply@github.com>- Parent
a87dca3
1 file changed+57 added−46 removed
modified:docs/content/manual/manual.yml+57 added-46 removed
3112 unmodified lines3113 3114 entries:3115 - title: "Update-assignment: `|=`"3116 body: |3117- This is the "update" operator '|='. It takes a filter on the3117+ This is the "update" operator `|=`. It takes a filter on the3118 right-hand side and works out the new value for the property3119 of `.` being assigned to by running the old value through this3120- expression. For instance, (.foo, .bar) |= .+1 will build an3121- object with the "foo" field set to the input's "foo" plus 1,3122- and the "bar" field set to the input's "bar" plus 1.3120+ expression. For instance, `(.foo, .bar) |= .+1` will build an3121+ object with the `foo` field set to the input's `foo` plus 1,3122+ and the `bar` field set to the input's `bar` plus 1.3123 3124 The left-hand side can be any general path expression; see `path()`.3125 3126- Note that the left-hand side of '|=' refers to a value in `.`.3126+ Note that the left-hand side of `|=` refers to a value in `.`.3127 Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is3128 not a valid or useful path expression in `.`); use `$var |3129 .foo |= . + 1` instead.3130 24 unmodified lines3155 - title: "Plain assignment: `=`"3156 body: |3157 3158 This is the plain assignment operator. Unlike the others, the3159- input to the right-hand-side (RHS) is the same as the input to3160- the left-hand-side (LHS) rather than the value at the LHS3159+ input to the right-hand side (RHS) is the same as the input to3160+ the left-hand side (LHS) rather than the value at the LHS3161 path, and all values output by the RHS will be used (as shown3162 below).3163 3164- If the RHS of '=' produces multiple values, then for each such3164+ If the RHS of `=` produces multiple values, then for each such3165 value jq will set the paths on the left-hand side to the value3166 and then it will output the modified `.`. For example,3167- `(.a,.b)=range(2)` outputs `{"a":0,"b":0}`, then3167+ `(.a,.b) = range(2)` outputs `{"a":0,"b":0}`, then3168 `{"a":1,"b":1}`. The "update" assignment forms (see above) do3169 not do this.3170 3171- This example should show the difference between '=' and '|=':3171+ This example should show the difference between `=` and `|=`:3172 3173- Provide input '{"a": {"b": 10}, "b": 20}' to the programs:3173+ Provide input `{"a": {"b": 10}, "b": 20}` to the programs3174 3175 .a = .b3176 3177+ and3178+3179 .a |= .b3180 3179- The former will set the "a" field of the input to the "b"3180- field of the input, and produce the output {"a": 20, "b": 20}.3181- The latter will set the "a" field of the input to the "a"3182- field's "b" field, producing {"a": 10, "b": 20}.3181+ The former will set the `a` field of the input to the `b`3182+ field of the input, and produce the output `{"a": 20, "b": 20}`.3183+ The latter will set the `a` field of the input to the `a`3184+ field's `b` field, producing `{"a": 10, "b": 20}`.3185 3184- Another example of the difference between '=' and '|=':3186+ examples:3187+ - program: .a = .b3188+ input: '{"a": {"b": 10}, "b": 20}'3189+ output: '{"a":20,"b":20}'3190 3186- null|(.a,.b)=range(3)3191+ - program: .a |= .b3192+ input: '{"a": {"b": 10}, "b": 20}'3193+ output: '{"a":10,"b":20}'3194 3188- outputs '{"a":0,"b":0}', '{"a":1,"b":1}', and '{"a":2,"b":2}',3189- while3195+ - program: (.a, .b) = range(3)3196+ input: 'null'3197+ output:3198+ - '{"a":0,"b":0}'3199+ - '{"a":1,"b":1}'3200+ - '{"a":2,"b":2}'3201 3191- null|(.a,.b)|=range(3)3202+ - program: (.a, .b) |= range(3)3203+ input: 'null'3204+ output: '{"a":0,"b":0}'3205 3193- outputs just '{"a":0,"b":0}'.3194-3206 - title: Complex assignments3207 body: |3208 Lots more things are allowed on the left-hand side of a jq assignment3209 than in most languages. We've already seen simple field accesses on44 unmodified lines3254 importer to alter this path.3255 3256 Paths in the a search path are subject to various substitutions.3257 3247- For paths starting with "~/", the user's home directory is3248- substituted for "~".3258+ For paths starting with `~/`, the user's home directory is3259+ substituted for `~`.3260 3250- For paths starting with "$ORIGIN/", the path of the jq executable3251- is substituted for "$ORIGIN".3261+ For paths starting with `$ORIGIN/`, the path of the jq executable3262+ is substituted for `$ORIGIN`.3263 3253- For paths starting with "./" or paths that are ".", the path of3254- the including file is substituted for ".". For top-level programs3264+ For paths starting with `./` or paths that are `.`, the path of3265+ the including file is substituted for `.`. For top-level programs3266 given on the command-line, the current directory is used.3267 3268 Import directives can optionally specify a search path to which3269 the default is appended.4 unmodified lines3274 3275 Null and empty string path elements terminate search path3276 processing.3277 3267- A dependency with relative path "foo/bar" would be searched for in3268- "foo/bar.jq" and "foo/bar/bar.jq" in the given search path. This3278+ A dependency with relative path `foo/bar` would be searched for in3279+ `foo/bar.jq` and `foo/bar/bar.jq` in the given search path. This3280 is intended to allow modules to be placed in a directory along3281 with, for example, version control files, README files, and so on,3282 but also to allow for single-file modules.3283 3284 Consecutive components with the same name are not allowed to avoid3274- ambiguities (e.g., "foo/foo").3285+ ambiguities (e.g., `foo/foo`).3286 3287 For example, with `-L$HOME/.jq` a module `foo` can be found in3288 `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.3289 3279- If "$HOME/.jq" is a file, it is sourced into the main program.3290+ If `$HOME/.jq` is a file, it is sourced into the main program.3291 3292 entries:3293 - title: "`import RelativePathString as NAME [<metadata>];`"3294 body: |3295 3296 Imports a module found at the given path relative to a3286- directory in a search path. A ".jq" suffix will be added to3297+ directory in a search path. A `.jq` suffix will be added to3298 the relative path string. The module's symbols are prefixed3288- with "NAME::".3299+ with `NAME::`.3300 3301 The optional metadata must be a constant jq expression. It3291- should be an object with keys like "homepage" and so on. At3292- this time jq only uses the "search" key/value of the metadata.3302+ should be an object with keys like `homepage` and so on. At3303+ this time jq only uses the `search` key/value of the metadata.3304 The metadata is also made available to users via the3305 `modulemeta` builtin.3306 3296- The "search" key in the metadata, if present, should have a3307+ The `search` key in the metadata, if present, should have a3308 string or array value (array of strings); this is the search3309 path to be prefixed to the top-level search path.3310 3311 - title: "`include RelativePathString [<metadata>];`"3312 body: |3313 3314 Imports a module found at the given path relative to a3315 directory in a search path as if it were included in place. A3305- ".jq" suffix will be added to the relative path string. The3316+ `.jq` suffix will be added to the relative path string. The3317 module's symbols are imported into the caller's namespace as3318 if the module's content had been included directly.3319 3320 The optional metadata must be a constant jq expression. It3310- should be an object with keys like "homepage" and so on. At3311- this time jq only uses the "search" key/value of the metadata.3321+ should be an object with keys like `homepage` and so on. At3322+ this time jq only uses the `search` key/value of the metadata.3323 The metadata is also made available to users via the3324 `modulemeta` builtin.3325 3326 - title: "`import RelativePathString as $NAME [<metadata>];`"3327 body: |3328 3329 Imports a JSON file found at the given path relative to a3319- directory in a search path. A ".json" suffix will be added to3330+ directory in a search path. A `.json` suffix will be added to3331 the relative path string. The file's data will be available3332 as `$NAME::NAME`.3333 3334 The optional metadata must be a constant jq expression. It3324- should be an object with keys like "homepage" and so on. At3325- this time jq only uses the "search" key/value of the metadata.3335+ should be an object with keys like `homepage` and so on. At3336+ this time jq only uses the `search` key/value of the metadata.3337 The metadata is also made available to users via the3338 `modulemeta` builtin.3339 3329- The "search" key in the metadata, if present, should have a3340+ The `search` key in the metadata, if present, should have a3341 string or array value (array of strings); this is the search3342 path to be prefixed to the top-level search path.3343 3344 - title: "`module <metadata>;`"3 unmodified lines3348 proper operation. It serves only the purpose of providing3349 metadata that can be read with the `modulemeta` builtin.3350 3351 The metadata must be a constant jq expression. It should be3341- an object with keys like "homepage". At this time jq doesn't3352+ an object with keys like `homepage`. At this time jq doesn't3353 use this metadata, but it is made available to users via the3354 `modulemeta` builtin.3355 3356 - title: "`modulemeta`"3357 body: |3358 3359 Takes a module name as input and outputs the module's metadata3360 as an object, with the module's imports (including metadata)3350- as an array value for the "deps" key.3361+ as an array value for the `deps` key.3362 3363 Programs can use this to query a module's metadata, which they3364 could then use to, for example, search for, download, and3365 install missing dependencies.40 unmodified lines