[syntax_tools + doctest] Add some (a lot of) examples to exported functions - #11393
[syntax_tools + doctest] Add some (a lot of) examples to exported functions#11393kvakvs wants to merge 1 commit into
Conversation
CT Test Results 2 files 13 suites 3m 16s ⏱️ Results for commit 113ae34. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
3adf605 to
5dcc119
Compare
|
Thanks for the PR! I don't think we want this as-is, the vast majority of the added examples don't add anything of value. Can you try to condense them down to the ones you thought were useful? The size makes the PR difficult to review. |
In my opinion, those examples, which build language constructs from pieces and demonstrate how they fit together, bring value, and that's at least 3/4 of the examples. Intended for people who didn't work with The remaining examples, e.g. setters and getters and debug info, line info, annotations, might have small value, and can be removed. |
Please pick one as an example. |
|
For example, constructing types (record type) RTF = erl_syntax:record_type_field(erl_syntax:atom(name), erl_syntax:atom(string)).
RT = erl_syntax:record_type(erl_syntax:atom(person), [RTF]).or constructing comprehensions with binaries and binary fields V = erl_syntax:variable("Byte").
BG = erl_syntax:binary_generator(V, erl_syntax:binary([erl_syntax:binary_field(erl_syntax:integer(65))])).
BC = erl_syntax:binary_comp(erl_syntax:binary_field(V), [BG]). |
|
Yes, so keep those, and skip the ones that are trivial (e.g. |
2f22a7d to
c0bdef5
Compare
c0bdef5 to
113ae34
Compare
| @@ -3435,6 +3598,7 @@ arity_qualifier(Body, Arity) -> | |||
| Returns the body subtree of an `arity_qualifier` node. | |||
|
|
|||
| _See also: _`arity_qualifier/2`. | |||
| ``` | |||
| "B <- [2]" | ||
| 5> ZG = erl_syntax:zip_generator([G1, G2]). | ||
| 6> erl_prettypr:format(ZG). | ||
| "A <- [1]&& B <- [2]" |
There was a problem hiding this comment.
erl_prettypr should really be fixed to insert a space before the &&...
| @@ -8165,6 +8917,7 @@ it does not necessarily have the same data representation as `Node`. | |||
|
|
|||
| _See also: _`copy_attrs/2`, `is_leaf/1`, `subtrees/1`, `type/1`, | |||
| `update_tree/2`. | |||
| ``` | |||
| 1> T = erl_syntax:tree(example, [erl_syntax:atom(ok)]). | ||
| 2> D = erl_syntax:data(T). |
There was a problem hiding this comment.
| 1> T = erl_syntax:tree(example, [erl_syntax:atom(ok)]). | |
| 2> D = erl_syntax:data(T). | |
| 1> Data = [erl_syntax:atom(ok)]. | |
| 2> Tree = erl_syntax:tree(example, Data). | |
| 3> Data =:= erl_syntax:data(Tree). | |
| true |
maybe something like this?
Changes
erl_syntax.erlhave been visited and some sort of doctest example was added where reasonable.syntax_tools_SUITE