Closed jpluscplusm closed 7 months ago
Audit of which functions have examples on their godoc page: https://alpha.cuelang.org/play/?id=44iZ2XN1Bxd#w=function&i=cue&f=eval&o=cue
My suggestions for which functions we could include in the initial round of alpha docs, created in line with:
strings.To*
and strings.Trim*
, where I feel the potential for user confusion is pretty lowI've included list.*
as IMHO the majority of its functions disproportionately deserve a good example given list's unique place as a non-primitive type that doesn't have the advantages of structs' (easy!) mergeability. There are probably individual list
functions I'll discover that don't merit a stand alone example right now - I'll pass lightly over those without trying to craft the perfect guide.
encoding/
base64.Decode
+base64.Encode
: https://cuelang.org/cl/1174178csv.Decode
+csv.Encode
: https://cuelang.org/cl/1174183json.Compact
+json.Indent
: https://cuelang.org/cl/1175999json.Marshal
+yaml.Marshal
: I'm stuck for ideas on what scenario to use to demonstrate these, as displaying any output variable that might contain their responses might as well be performed with cue export --out json/yaml
.encoding/json.Marshal
to ...", without the answer being "just use cue export --out json
", instead of "use json.Marshal".json.Validate
+yaml.Validate
+yaml.ValidatePartial
: https://cuelang.org/cl/1176034list/
Avg
+Max
+Min
+Sum
: https://cuelang.org/cl/1174381Contains
: https://cuelang.org/cl/1174384MaxItems
+MinItems
: https://cuelang.org/cl/1174389SortStrings
+IsSortedStrings
+Sort
+IsSorted
: https://cuelang.org/cl/1174391FlattenN
: https://cuelang.org/cl/1174439UniqueItems
: https://cuelang.org/cl/1174648Concat
: https://cuelang.org/cl/1174726Take
+Drop
+Slice
: Unsure if it's worth including these, given their similarity to the core language foo[x:y]
syntax. No-one's disagreed in Slack yet, either.Range
: The authoritative stdlib docs seem sufficient.Repeat
: The authoritative stdlib docs seem sufficient.net/
IP
+IPv4
+IPCIDR
: https://cuelang.org/cl/1174202ParseIP
+IPString
: https://cuelang.org/cl/1174210FQDN
: not documenting this for now, given that #2431 causes it to accept (pretty much) any FQDN - even invalid ones. path/
Base
+Dir
+Ext
: https://cuelang.org/cl/1174212FromSlash
+ToSlash
: not including these for now, as their "simple" behaviours as text modifiers is pretty easy to understand and the stdlib docs are self-explanatory. However, one of their (main?) use cases is inside cue cmd
tooling, where system variable injection allows a definitive path to be kept in the CUE file and then adapted, on the fly, for whichever OS the command finds itself running on. Demonstrating /this/ needs some thought; parking this pair of functions for now. Join
: https://cuelang.org/cl/1174728regexp/
ReplaceAll
+ReplaceAllLiteral
: https://cuelang.org/cl/1174750Match
: Pausing on this, as closer inspection suggests that this function is close match to the core language syntax of foo: =~"^a reg[ex]$"
, but with the disadvantage of not working as a field validator. strconv/
strings/
Contains
+HasPrefix
+HasSuffix
: https://cuelang.org/cl/1174729Join
: Pausing as per Split
, below.Replace
: https://cuelang.org/cl/1174748Split
: Pausing on this to consider if it should be demonstrated alongside Join
, or alongside all the Split*
variants, or both.text/
template.Execute
: https://cuelang.org/cl/1174775Closed as of https://github.com/cue-lang/cuelang.org/commit/0d7f4b28d07cc8617be2209c7c6d767cae8cb9bb.
We'll see how folks get on with the currently documented function examples, and address any gaps on an ongoing basis.
Let's add a commented CUE how-to guide for any functions in the standard library that would benefit from a clear example of the function.
For each standard library
<package>.<function>
that would benefit:/docs/howto/use-the-standard-<package>-<function>-function-to-<task>
<task>
which demonstrates the most common use case of the functionFor each
<package>
:Add a tag for these pages.
builtin
?stdlib
?