-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New EEP: Module attributes for documentation #24
Conversation
First, attributes without parens is weird. :-) I agree about wanting a different solution than code comments. Comments are not documentation. I disagree about documentation in the source code being easier to keep in sync, it gets out of date just as easily as external documentation. On the other hand when the documentation is in the source code it's easier to sneek in potentially breaking documentation changes unnoticed. As a result I would much prefer to keep external documentation but still make use of these attributes, perhaps via something like:
This would close any debate about documentation inside or outside the source code since both would be possible. There is also no issues around quotes when using external documentation. I suppose a compile flag could be added to locate the external files more easily, though |
eeps/eep-0057.md
Outdated
Copyright | ||
========= | ||
|
||
This document has been placed in the public domain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should strictly describe license, like CC0, as not all jurisdictions allow voluntary assigning document to public domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the standard of all other EEPs, so I won't change it, but perhaps this conversation needs to brought up elsewhere? Or maybe it only matters for what is valid in Sweden in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josevalim created #25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, the templates were copied from PEP, so this phrasing is likely just an old artefact. I agree it should be changed to CC0. In many countries (including most of Europe) saying "this is placed in the public domain" does not have any legal effect. Copyright is automatic as of the Berne convention of 1988.
@essen thank you for the comments and the suggestion. I will amend the proposal to allow embedding external documents too. It may be a bit repetitive to provide a path for each doc but I guess someone could write a parse transform that maps everything in a directory to moduledoc+doc if they really want to reduce the duplication? |
another attribute 'include_doc' could be introduced for inclusion of doc
written in other files than the source code file. That would make it
possible to mix doc written in the source file with doc written outside in
a flexible way.
…On Wed, Jun 2, 2021 at 1:25 PM José Valim ***@***.***> wrote:
@essen <https://github.com/essen> thank you for the comments and the
suggestion. I will amend the proposal to allow embedding external documents
too. It may be a bit repetitive to provide a path for each doc but I guess
someone could write a parse transform that maps everything in a directory
to moduledoc+doc if they really want to reduce the duplication?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#24 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFWSF2OCPXZ2BVZ6KEICDTQYIMDANCNFSM456M73PQ>
.
|
An EEP should have line breaks as any Markdown document (that follows E-Mail conventions).
|
@RaimoNiskanen updated! @essen and @KennethL, I added a section about supporting |
Yes no problem about metadata. |
eeps/eep-0057.md
Outdated
The new `-moduledoc` attribute can be listed anywhere and it will contain | ||
the documentation for the given module. The `-doc` attribute must be | ||
listed once before each function and it will contain the documentation | ||
for the following function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ordering preferences compared to type specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ferd please expand? I am not sure I follow the question. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People have a tendency to do something like:
%% @doc This function turns the programmer into a much more productive one
-spec levelup(programmer()) -> programmer().
levelup(Programmer) -> Programmer*10.
The new literal translation would be:
-doc "This function turns the programmer into a much more productive one".
-spec levelup(programmer()) -> programmer().
levelup(Programmer) -> Programmer*10.
This will work with the spec above if we read "listed once before each function", meaning there can be one -doc
attribute before any function and it will get assigned to the one that follows.
However the spec could also force the following if we read it to mean "the doc must be listed once right before each function":
-spec levelup(programmer()) -> programmer().
-doc "This function turns the programmer into a much more productive one".
levelup(Programmer) -> Programmer*10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. We don't look at other attributes, so it can be anywhere before a function. I will clarify.
eeps/eep-0057.md
Outdated
`u"Héllò World"`. While adding such construct is not a direct part | ||
of this EEP, the point made in this subsection is that, if we require | ||
the documentation or its metadata to be a binary, we may need to | ||
provide conveniences for writing UTF-8 binary strings in Erlang. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, to me, would point towards supporting both formats and converting. Erlang strings should represent safe unicode data that can be converted later with unicode:characters_to_binary(CharData)
and for the time being provides safe unicode with low syntactic overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I agree with you. What about metadata? Should it be automatically rewritten too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could make sense. I'd see this as an extension of all Erlang-style things where CharData
gets flattened down for you when possible. It would in principle not harm anything as long as you specify you expect data to be UTF-8 compatible, meaning raw strings, binaries in the utf8 encoding, or lists of either of these.
ASCIDoc has built-in support for document metadata via attributes. So with "smart enough" implementation the metadata could be stored in the external files as well. |
I would suggest keeping the external file format implementation not smart to begin with and build upon them later if there's strong interest. Asciidoc attributes are one option, but there's also Hugo-like header variables that work with any file format for example. |
Any thoughts on the warning similar to |
@moiseev I have added a section mentioning this feature could also be added in the future too, thanks! |
@essen that was what I meant. It shouldn't be Erlang concern to understand and extract metadata from documentation, but the documentation processor (external) should be able to achieve something like that in future. |
This seems like a fantastic proposal that would simplify dealing with in-code documentation significantly compared to edoc comments. Is there anything I could do to help move this forward? |
Can you please change the file name to eep-0059.md and I will merge this PR so we can refer to it as EEP-59 |
@KennethL done! I have also updated some parts with the feedback received in this PR. |
I pushed again to make the linter happy! |
No description provided.