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
We are now working towards saving the module, function and macro documentation strings in the .beam file. As a first step along the way the define-function and define-macro core forms not have an extra element for the documentation strings. The macro expander now saves the documentation string from the defun and defmacro in the forms when they are expanded. The doc strings are then passed through the compiler where they are ignored except in the lint pass where they are checked that they are either list character strings or binaries.
It is @yurrriq who is doing the actual work around this.
I think the based place to get these strings is after the split pass and before the expand pass in the compiler because between these two the macro definitions are still in the code forms. After the expand pass all macros have been expanded and their definitions are no longer saved. Then they have to be saved of course which is where it starts getting interesting. :-)
You can actually comment local function and macro definitions:
(flet ((sune (a b)
"The sune function."
(* a b)))
...)
However, these comments are lost, mainly because I don't know what to do with them.
Yes, I made a mistake and managed to delete the initial commit :-( That is why I made an issue of it so it won't be in any commit and that won't happen again. I don't trust myself.
Ok, I'm getting close to resolving all the conflicts. I'm going to rework the doc parsing s.t. it only happens in a do_docs pass when you mentioned above. Will likely pull out the helper functions into a new module, lfe_doc.
I have been thinking about the compiler. One problem with doing it after split and before the expand passes is just the expansion. The reason is that the split pass only expands the forms at the top-level so it can detect define-module and partition the forms into modules. Everything before the first module is copied into every module. The expand pass, however, expands everything all the way down but it removes the macro definitions.
So what could happen is that in a function defined by a match-lambda there might be macros in the arguments which will only be expanded in the expand pass. This will mean that your argument descriptions may be off. This does not happen if the functions is a lambda.
I don't know if this is a problem but if it is we can fix it later.
I'm pretty satisfied at this point, but the question is: do we want to do anything analogous to Elixir's moduledoc, callback_docs and type_docs?
My thoughts: type_docs probably doesn't make much sense for us (for now), nor does callback_docs. It could be quite nice, however, to put a module's docstring in moduledoc. I'm not sure what Elixir stores there, but it's probably worth looking into that too.
OTOH...
> (iolist_to_binary (proplists:get_value'doc (example:module_info 'attributes) []))
#"This is an example module."
Yes I would have a module-doc similar to elixir's and I would (will) remove that attribute from the module attributes when generating the .beam file. The reason being that I want all the documentation in the separate LDoc chunk as it can become very large and you can easily remove it when you want to. For example with beam_lib:strip_release/1.
I would prune LFE-EXPAND-EXPORTED-MACRO/3 and MODULE/0 and some other predefined stuff as well. In one sense they don't really exist.
No, I will fix the PDF stuff, almost got it working. Then I will clean up
develop and merge it into master as 1.0.2, then you can rebase your stuff
and I will pull it.
No, I will fix the PDF stuff, almost got it working. Then I will clean up
develop and merge it into master as 1.0.2, then you can rebase your stuff
and I will pull it.
The problem is the latin1 characters and two unicode codepoints in the
source. And you get different problems depending on what you are generating:
The pdf can't handle 2 latin1 chars and no unicode codepoints at all, but
everything goes fine. Maybe there is a switch which can fix this.
The man page doesn't seem to be able to handle anything above 128. Well
it can handle it but the output is unintelligible.
The textfile works ok except for a few latin1 chars.
Do you know of any options which may help me then let me know. My plan is
to rewrite those sections and just mention the char ranges, not explicitly
show them.
I'm not sure about those issues, but I've pushed a crucial fix for the to_* steps, as well as some general cleanup and tooling improvements. I won't link to commits, since they'll likely get rebased soon, but you can look at the log of my branch.
We could solve that by moving the comment pass until after the macro
expansion. Currently that would mean the macros are gone but that would be
easily fixed by leaving them and ignoring them later.
The question is: is the LDoc chunk going to be used for more than just display purposes, i.e. do we need to ensure (length pattern) remains accurate? Or can we use a hack to make sure it "looks right" and tell users to use the arity field if they need to, rather than (length pattern)?
Activity
Add docs string element to define-function/macro core form
yurrriq commentedon Mar 27, 2016
The commit has since been rebased away, but there's some discussion here.
rvirding commentedon Mar 27, 2016
Yes, I made a mistake and managed to delete the initial commit :-( That is why I made an issue of it so it won't be in any commit and that won't happen again. I don't trust myself.
yurrriq commentedon Mar 27, 2016
I think it was me aggressively rebasing 😄
yurrriq commentedon Mar 27, 2016
Ok, I'm getting close to resolving all the conflicts. I'm going to rework the doc parsing s.t. it only happens in a
do_docspass when you mentioned above. Will likely pull out the helper functions into a new module,lfe_doc.rvirding commentedon Mar 27, 2016
Would you like me to wait with Duncan's doc PR? It shouldn't affect you but who knows.
yurrriq commentedon Mar 27, 2016
It looks safe to me.
rvirding commentedon Mar 28, 2016
I have been thinking about the compiler. One problem with doing it after split and before the expand passes is just the expansion. The reason is that the split pass only expands the forms at the top-level so it can detect define-module and partition the forms into modules. Everything before the first module is copied into every module. The expand pass, however, expands everything all the way down but it removes the macro definitions.
So what could happen is that in a function defined by a
match-lambdathere might be macros in the arguments which will only be expanded in the expand pass. This will mean that your argument descriptions may be off. This does not happen if the functions is alambda.I don't know if this is a problem but if it is we can fix it later.
yurrriq commentedon Mar 31, 2016
After my latest efforts (and some more rebasing 😈), the output of test/docs.lfe looks like:
Note the
patternsandexportedbooleans. For convenience, here's the#doc{}definition, which now lives in src/lfe_doc.hrl:yurrriq commentedon Mar 31, 2016
I'm pretty satisfied at this point, but the question is: do we want to do anything analogous to Elixir's
moduledoc,callback_docsandtype_docs?My thoughts:
type_docsprobably doesn't make much sense for us (for now), nor doescallback_docs. It could be quite nice, however, to put a module's docstring inmoduledoc. I'm not sure what Elixir stores there, but it's probably worth looking into that too.OTOH...
yurrriq commentedon Mar 31, 2016
One more thing, do we want to prune
LFE-EXPAND-EXPORTED-MACRO/3andMODULE/0, or leave them there for accuracy?rvirding commentedon Mar 31, 2016
Nice. Some answers to your questions:
module-docsimilar to elixir's and I would (will) remove that attribute from the module attributes when generating the .beam file. The reason being that I want all the documentation in the separate LDoc chunk as it can become very large and you can easily remove it when you want to. For example withbeam_lib:strip_release/1.LFE-EXPAND-EXPORTED-MACRO/3andMODULE/0and some other predefined stuff as well. In one sense they don't really exist.yurrriq commentedon Mar 31, 2016
I've pushed some hacks to those ends.
Current output of
lfe test/docs.lfe:yurrriq commentedon Mar 31, 2016
Note that
docis removed fromattributesnow:yurrriq commentedon Mar 31, 2016
@rvirding, shall I remove
export-macrotoo?16 remaining items
yurrriq commentedon Apr 1, 2016
I can try to take a look at the PDF issues tonight too.
rvirding commentedon Apr 1, 2016
No, I will fix the PDF stuff, almost got it working. Then I will clean up
develop and merge it into master as 1.0.2, then you can rebase your stuff
and I will pull it.
Robert
On 2 April 2016 at 01:32, Eric Bailey [email protected] wrote:
rvirding commentedon Apr 1, 2016
Do you know if you can comment a line in MD?
On 2 April 2016 at 01:35, Robert Virding [email protected] wrote:
yurrriq commentedon Apr 1, 2016
You do it HTML style:
<!-- this is a comment -->rvirding commentedon Apr 2, 2016
Yes, that works, thank you.
The problem is the latin1 characters and two unicode codepoints in the
source. And you get different problems depending on what you are generating:
everything goes fine. Maybe there is a switch which can fix this.
it can handle it but the output is unintelligible.
Do you know of any options which may help me then let me know. My plan is
to rewrite those sections and just mention the char ranges, not explicitly
show them.
Robert
On 2 April 2016 at 01:38, Eric Bailey [email protected] wrote:
yurrriq commentedon Apr 3, 2016
I'm not sure about those issues, but I've pushed a crucial fix for the
to_*steps, as well as some general cleanup and tooling improvements. I won't link to commits, since they'll likely get rebased soon, but you can look at the log of my branch.yurrriq commentedon Apr 3, 2016
XeLaTeX might be of use here. /cc @jgm
rvirding commentedon Apr 3, 2016
What I have done now is to quite simply remove all the unicode and upper
latin-1 characters. I just have to shift some bits to the left and I am
done.
Robert
On 3 April 2016 at 21:40, Eric Bailey [email protected] wrote:
yurrriq commentedon Apr 4, 2016
Based on #216, I've started writing
doc/1and similar. You can find a snapshot here or here.yurrriq commentedon Apr 4, 2016
The process has exposed a bug/feature of
lfe_docthat may need correcting:Edit: Check out the workaround I adopted from Lodox,
format-patterns/1.The question remains: Do we want to handle this in
lfe_docor let/force consumers to handle it?rvirding commentedon Apr 4, 2016
Do you mean not expanding the backspace macro?
We could solve that by moving the comment pass until after the macro
expansion. Currently that would mean the macros are gone but that would be
easily fixed by leaving them and ignoring them later.
Robert
On 4 April 2016 at 08:46, Eric Bailey [email protected] wrote:
yurrriq commentedon Apr 4, 2016
I mean when you use quasiquoting in function clauses, the show up as
(,x comma xs)inpatterns.yurrriq commentedon Apr 10, 2016
I think we should leave the
do_docspass where it is and add a function that sanitizes patterns.yurrriq commentedon Apr 10, 2016
The question is: is the LDoc chunk going to be used for more than just display purposes, i.e. do we need to ensure
(length pattern)remains accurate? Or can we use a hack to make sure it "looks right" and tell users to use thearityfield if they need to, rather than(length pattern)?