-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
RFC 0011: Extending API Docs #11
base: main
Are you sure you want to change the base?
RFC 0011: Extending API Docs #11
Conversation
This pull request has been mentioned on Crystal Forum. There might be relevant details there: https://forum.crystal-lang.org/t/rfc-extending-api-docs-and-compiler-semantic-output/7314/22 |
Strongly in favor of this. I agree with some of the commenters on the forum that documenting methods that nobody but the library authors will ever use is not a great idea, but sometimes the intended audience of a In my case, I have an ORM called Interro where your query objects inherit from a framework type. Methods like struct PostQuery < Interro::QueryBuilder(Post)
def by(author : User)
where author_id: author.id
end
def published
where { |post| post.published_at < Time.utc }
end
def in_reverse_chronological_order
order_by created_at: :desc
end
end In this example, note that I'm implementing my query object's methods in terms of author_feed = PostQuery.new
.by(author)
.published
.in_reverse_chronological_order If I were able to call Application developers should be able to see what methods are available to them inside their query objects, so it's important to be able to document them at the very least. |
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.
Thank you for this proposal 🙇
Co-authored-by: Julien Portalier <[email protected]>
Co-authored-by: Julien Portalier <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
Definitely in favour of this proposal, it seems useful, and the design is in keeping with the rest of the doc generator. One thing to keep an eye on is that the doc generator makes the visibility (protected/private) of the method clear and obvious in the generated docs. It should be impossible to miss. |
If I can suggest one possibility, when a |
Co-authored-by: Stephanie Wilde-Hobbs <[email protected]>
Co-authored-by: Stephanie Wilde-Hobbs <[email protected]>
Co-authored-by: Stephanie Wilde-Hobbs <[email protected]>
Other people in the past have mentioned having separate sections for private and protected methods, would that work? My previous implementation just put the visibility next to the method name (as it would look in code) |
I'm ambivalent about having a separate section, I mostly wanted to make a point about the visual distinctiveness of the visibility modifier when looking at a single method. You can't rely on sections for this because the section is context you can forget if the section marker is off-screen, and therefore doesn't contribute to being immediately obvious. |
Is there anything else to do for this RFC to be merged? Want to get started on this for Crystal 1.15 if possible. |
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.
LGTM.
I only have some minor suggestions to polish the language. But none of them are blockers.
The general is well received, so I think we can already start on the implementation and finish the RFC in parallel.
I expect that we might only notice some issues that need clarification by using an actual implementation and testing it.
|
||
# Motivation | ||
|
||
Currently, API documentation is not generated for private/protected methods/objects or C lib binding objects. |
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.
polish: Perhaps it would be helpful to use a single term for documented things (methods, types, constants, macros, functions, ...). I think "object" fits great. Maybe we could introduce that here and mention what it refers to, and then later occurences in the text could simplify to the term "(documented) objects"? (This is already happening in some places, actually)
For example:
@@ -23,1 +23,1 @@
-The `:showdoc:` directive can be added to private or protected objects, methods, and C lib bindings, to have them show up in API documentation.
+The `:showdoc:` directive can be added to `private` or `protected` objects, and objects in `lib` bindings, to have them show up in API documentation.
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.
I'm not sure about the "object" word. It's very connoted for me as type instances and has zero relationship with methods or C symbols 😕
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.
Maybe "features" then?
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
This pull request has been mentioned on Crystal Forum. There might be relevant details there: |
This RFC is a follow up to discussion on the Crystal forum.