You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It now works but there are a few issues which I think needs discussing up:
Now the argument information is stored and returned for every function and macro even if it doesn't have any documentation. Should this only be done when there is documentation?
Now the function/macro arguments haven't been macro expanded. Should it be like this? Should we see the arguments as they are written or as they "really" are? The compiler internals as they are today enforce the current way but it would be easy to change this if we wish.
Internally should we delay processing the documentation until have checked the code? This would require the change to the compiler internals as in the previous issue.
Should we store information for undocumented definitions?
I think so. Often the name, arity and arguments can be informative in and of themselves.
Should the arguments be macro expanded?
I think I've changed my mind on this and now want arguments macro expanded.
That would make the job easier for further tooling (e.g. lodox or {doc,describe,help}/1).
Should we delay processing until the code is checked?
Probably. It's inefficient to execute the do_docs step if the compilation will ultimately fail. lfe_doc also basically assumes correct code (though there is a bit of error handling).
OK, my plan is that I will first fix the internals of the compiler so we can move the collecting of the docs until after the code has been checked. This will also mean that the function/macro arguments will be expanded.
We can then discuss if we want to keep argument info for functions/macros without docs.
I have just pushed a commit which moves the documentation till after the syntax pass. This is more logical and makes the code easier to work with. There are now some changes I will (probably) be making:
Only add the docs for exported functions and macros. I don't think module internal stuff should leak out.
I still think we should only add and save the argument patterns for functions and macros which have documentation.
Now we just need some interface functions for accessing and printing the data and we are done.
FWIW Codox handles undocumented, but public, definitions, similar to how we're doing it now. Perhaps there's a way we can ignore definitions generated by the compiler, e.g. L-E-E-M, and those that come from an include-lib or include-file. Is that feasible/agreeable?
OK, I will leave it as it is for the exported public functions and macros but not include the internal ones. And I will include the argument documentation even if there is no user docs. I make sure all the automatically generated functions and macros are not documented.
I will add a simple interface in the REPL, I had a an idea that that would also handle elixir documentation as well. Just to poke them a bit that we can use theirs. :-)
I don't think so as they should all be expanded with the macros, the `` , ,@` are actually macros. Lint doesn't see them anyway. This should make it easier to do the pattern checking as well as you know that the patterns are all correct, even in the macros, at least those which have been used.
Did we decide on a name? I like doc/{1,3} (as it is currently in my ldoc repo), but there's been talk of help or describe too. My idea is to support ({{name}} m f a) as well as ({{name}}} #(m f a)) and perhaps alternatives without arity as I've written some search functionality. We could do one with just module too. Thoughts?
OK, I am working on just saving the exported functions and macros. I seriously wonder if macros should have number of arguments. Basically they just get a list of arguments which can be matched in any way. Maybe either ignore the arity field for macros in #doc{} or drop it completely and make the name field be {Name,Arity} for functions and just Name for macros.
No I think we should leave it. You mentioned a private-docs flag for the compiler which would also generate the documentation for private files. For that we need to keep track of which is which. I am making some small changes to the lfe_doc API which will allow this later if we wish.
Pasting the snippet for metadata syntax from Slack:
(define-function ->binary
;; implicit 'meta'
((spec ((list) binary)
((binary) binary))
(abritary true)
;; position of (doc ...) doesn't matter
(doc "Given a string or a binary, return a binary.")
(something else))
(match-lambda
([str] (when (is_list str))
(unicode:characters_to_binary str 'utf8 'utf8))
([bin]
bin)))
(defunadder (x y)
"Add x and y."
(+ x y))
;; is equivalent to
(define-function adder
((doc "Add x and y."))
(lambda (x y) (+ x y)))
Users can also specify multiline docstrings as follows:
Activity
yurrriq commentedon Apr 17, 2016
I think so. Often the name, arity and arguments can be informative in and of themselves.
I think I've changed my mind on this and now want arguments macro expanded.
That would make the job easier for further tooling (e.g. lodox or
{doc,describe,help}/1).Probably. It's inefficient to execute the
do_docsstep if the compilation will ultimately fail.lfe_docalso basically assumes correct code (though there is a bit of error handling).rvirding commentedon Apr 18, 2016
OK, my plan is that I will first fix the internals of the compiler so we can move the collecting of the docs until after the code has been checked. This will also mean that the function/macro arguments will be expanded.
We can then discuss if we want to keep argument info for functions/macros without docs.
yurrriq commentedon Apr 18, 2016
Sounds good to me. It might be helpful to look at how Codox, Exdoc, et al. handle undocumented functions.
yurrriq commentedon Apr 22, 2016
I've started working on updating lodox to use the LDoc chunk.
See version 0.13.0 and the terribly satisfying diff:
rvirding commentedon Apr 23, 2016
I have just pushed a commit which moves the documentation till after the syntax pass. This is more logical and makes the code easier to work with. There are now some changes I will (probably) be making:
Now we just need some interface functions for accessing and printing the data and we are done.
yurrriq commentedon Apr 23, 2016
FWIW Codox handles undocumented, but public, definitions, similar to how we're doing it now. Perhaps there's a way we can ignore definitions generated by the compiler, e.g.
L-E-E-M, and those that come from aninclude-liborinclude-file. Is that feasible/agreeable?rvirding commentedon Apr 23, 2016
OK, I will leave it as it is for the exported public functions and macros but not include the internal ones. And I will include the argument documentation even if there is no user docs. I make sure all the automatically generated functions and macros are not documented.
I will add a simple interface in the REPL, I had a an idea that that would also handle elixir documentation as well. Just to poke them a bit that we can use theirs. :-)
yurrriq commentedon Apr 23, 2016
I've started messing around here.
rvirding commentedon Apr 23, 2016
OK, you work on that end of the problem while I do the compiler end and we can merge it into core LFE and call it from the REPL.
yurrriq commentedon Apr 23, 2016
Should it be written in Erlang instead of LFE? Maybe it should live in
lfe_doc.yurrriq commentedon Apr 23, 2016
Note that the pattern-formatting hack for forms like ``(,x . ,xs)is still needed even after moving thedo_docs` pass.rvirding commentedon Apr 23, 2016
I don't think so as they should all be expanded with the macros, the `` , ,@` are actually macros. Lint doesn't see them anyway. This should make it easier to do the pattern checking as well as you know that the patterns are all correct, even in the macros, at least those which have been used.
yurrriq commentedon Apr 23, 2016
Maybe I had a stale copy of LFE in my _build. I'll clear out and try again.
Update: Confirmed.
From the example output in my comment on #228:
yurrriq commentedon Apr 23, 2016
Did we decide on a name? I like
doc/{1,3}(as it is currently in my ldoc repo), but there's been talk ofhelpordescribetoo. My idea is to support({{name}} m f a)as well as({{name}}} #(m f a))and perhaps alternatives without arity as I've written some search functionality. We could do one with just module too. Thoughts?cc: @rvirding @oubiwann @arpunk
See also: #67 #115
oubiwann commentedon Apr 24, 2016
doc is Clojure and describe is CL; we could have both, one as an alias ...
rvirding commentedon Apr 24, 2016
OK, I am working on just saving the exported functions and macros. I seriously wonder if macros should have number of arguments. Basically they just get a list of arguments which can be matched in any way. Maybe either ignore the
arityfield for macros in#doc{}or drop it completely and make thenamefield be{Name,Arity}for functions and justNamefor macros.yurrriq commentedon Apr 26, 2016
Update: Now we're only saving exported definitions and macros don't have arity, e.g.
I think we can safely remove theexportedfield now too, as it will always betrue.rvirding commentedon Apr 26, 2016
No I think we should leave it. You mentioned a
private-docsflag for the compiler which would also generate the documentation for private files. For that we need to keep track of which is which. I am making some small changes to the lfe_doc API which will allow this later if we wish.yurrriq commentedon Apr 26, 2016
Ah, yes. Good point.
yurrriq commentedon May 17, 2016
Pasting the snippet for metadata syntax from Slack:
Users can also specify multiline docstrings as follows:
which will result in:
oubiwann commentedon Oct 14, 2020
Robert has since re-worked the docs code in LFE.
Closing ...