-
Notifications
You must be signed in to change notification settings - Fork 424
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
Should we provide a specific way to document attributes? #23149
Comments
I recommend two strategies (combined):
|
I am interested in prototyping this. I actually think that we can do this using procedures. Since Chapel attributes support actuals, and have names, I think we can create special 'attribute procedures', which are excluded from function resolution (perhaps they implicitly have a /** This attribute does bla bla bla... */
@attribute
proc assertOnGpu /* where false? */ {}
/** This attribute does bla bla bla */
@attribute(namespace="gpu")
proc blockSize(size: integral) {} This:
|
You had me until "allows users to document their custom attributes in a similar way". We haven't finalized the syntax for (or even if we want to support) custom attributes, and the only way to add an attribute today is to modify the compiler, so far as I know. Therefore I think we should hide any thing that might bleed implementation details and imply that users can define their own until it is actually possible for them to do so - this will avoid getting user questions about "why isn't this working, I wrote it like the docs". It will also allow us to transition from this shortcut to support that reflects the true complexity of the feature when custom attributes are possible. |
That said, I think what you've proposed is an excellent way to get support ready quickly, and I would be interested in being present in a meeting to brainstorm what exactly the output should look like |
When I said "user provided custom attributes" I meant tool attributes -- and I thought we have already "added support for it", in that we can pass a flag to the compiler to allow certain toolspaced attributes. Either way, we could disallow the |
Ooooh, I see. You mean for things that are recognized and responded to in programs outside of the Chapel compiler. And it makes sense that those would not be scenarios where a user is as likely to see an example and try it in a way that would frustrate them. I buy that. |
Closes #23149. This PR implements my initial vision for documenting attributes based on procedures that implement them. In PR #25826, I made GPU attributes be backed by Chapel functions. One of my goals with this approach was to be able to document these attributes using the existing Chapel mechanism (doc comments attached to procedures). This PR does so, by adding a new chpldoc attribute (`@chpldoc.attributeSignature`) that marks a function as defining the signature (formals etc.) of an attribute. Since the functions in the GPU module that back attributes are internal (not intended to be called directly), they would normally be skipped by chpldoc's output. This PR adjusts the behavior of chpldoc to not skip the functions in this case. It also adds documentation to the various attributes using this new mechanism. This PR depends on chapel-lang/sphinxcontrib-chapeldomain#97, which implements the RST-to-HTML conversion of the new 'annotation' directive chpldoc will emit. <img width="725" alt="Screen Shot 2024-09-05 at 10 16 43 AM" src="https://github.com/user-attachments/assets/bcc3fbe8-301f-4727-ae92-be2968d4e0f4"> Reviewed by @e-kayrakli, @mppf, and @lydia-duncan -- thanks! ## Testing - [x] paratest (just in case)
I'll start with context. We had
assertOnGpu()
standalone function that was documented in theGPU
module docs. We deprecated that in favor of@assertOnGpu
attribute on the loop. So, now, how can we document the new attribute? In the short term, I don't think it is a big deal to add a header under GPU technote.In general, should there be some special support for documenting attributes in
chpldoc
? While sticking something in a module code can be appealing and approachable as it can be similar to what we have been doing, it seems wrong. Attributes are a compiler/tool concept. So, attributes that we have should be documented in the compiler code where we "define" them. But how?Another question about this is how it should be rendered. An easy solution is to have an attribute index where we list every documented attribute. But it is also appealing to drop in attribute documentation into other rst files. For example, it would be great if the
assertOnGpu
documentation was in the GPU technote. If the same thing was redundantly in the attribute index, that wouldn't bother me. But maybe we can keep the index as just list of links where attributes are documented in related places like in spec, relevant module docs, or technotes.Arguably, there should be a style that can set aside attributes from other things we're documenting today.
The text was updated successfully, but these errors were encountered: