-
Notifications
You must be signed in to change notification settings - Fork 47
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
#362: add basic rst template for api documentation #385
Conversation
templates/api.rst
Outdated
- for subsections | ||
|
||
^ for subsubsections | ||
|
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.
There are often several ways for doing basic things (e.g., creating subsections). Is there a reason to prefer one way over another?
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 this is what's recommended, I just copy and pasted from https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
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 looks really good Nic. Many thanks for your help with this!
templates/api.rst
Outdated
Use the following convention for headings: | ||
|
||
# with overline, for parts | ||
|
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.
A general comment: I'm not familiar with some of the "Sphinx-isms," and other might not be, either.
For example, what is a "part" vs. a "chapter" (operationally speaking), and what does "overline" mean in both contexts?
Would it help either in the README or here to point people to the Sphinx Style Guide: https://documentation-style-guide-sphinx.readthedocs.io/en/latest/style-guide.html
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.
Hmm, this isn't exactly official and has some things like saying to use .txt
extensions that I don't agree with
templates/api.rst
Outdated
.. | ||
It may be useful to also have examples for individual functions above. | ||
|
||
Prefer examples to usage. |
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 put this idea ("Prefer examples to usage") up top, as a point of general guidance. A possible re-work of this sentence for clarity: "Prefer working, compile-able code to human-language description."
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 tried to make it clearer, but I think it should go further down rather at the top. Maybe we could have a more "general guidelines" page?
templates/api.rst
Outdated
|
||
#include<Kokkos_Core.hpp> | ||
#include<cstdio> | ||
|
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.
TODO: Amy, Nic + Francesco figure out Sphinx feature for correct rendering of C++ include statements
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.
@fnrizzi -- can you help w/ this rendering 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.
i don't think we have a way around, the include is inside the code block
templates/api.rst
Outdated
} | ||
|
||
Kokkos::finalize(); | ||
} |
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.
Meeting comments:
-
In the general example, add all possible "Kokkos-isms" so everyone can understand the available customizations and how to use them
-
Add template for classes to facilitate copy / paste
-
Fix header rendering
-
Create compiled version (Daniel A.)
-
Add Kokkos to Compiler Explorer, and make examples work interactively with it (Cezary S.)
-
Submit issue to Compiler Explorer to add Kokkos (done)
-
From Compiler Explorer site:
``` “To add a library, search for one you want and select the version in the dropdown. Or if you have favorited it before, just click the library name in the Favorites section. Libraries are installed |using the conan.io package manager, except for Microsoft compilers, where vcpkg is used.” ```
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.
Hey Nic -- It generally looks good, but a few changes might help (see embedded comments).
templates/api.rst
Outdated
} | ||
|
||
Kokkos::finalize(); | ||
} |
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.
WHOOPSIE! I missed this TODO:
- Add example to "Contributing" pages as a compiled example
- "Contributing"
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 added the template to "Contributing". I actually made a folder that we can add more templates to
templates/api.rst
Outdated
|
||
#include<Kokkos_Core.hpp> | ||
#include<cstdio> | ||
|
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.
@fnrizzi -- can you help w/ this rendering question?
26739a2
to
d863aee
Compare
I rebased and updated with some extra useful comments. |
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.
@nmm0 can you please post also in the PR a screenshot of what this looks like?
templates/api.rst
Outdated
|
||
#include<Kokkos_Core.hpp> | ||
#include<cstdio> | ||
|
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 don't think we have a way around, the include is inside the code block
docs/source/templates/class_api.rst
Outdated
.. | ||
Use the following convention for headings: | ||
|
||
# with overline, for parts |
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.
what are "parts"?
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 clarified this
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.
Hi Nic, Apologies for the late-in-the-day turn around, but there are a few things that are not clear to me. I'll be happy to work through these together.
docs/source/templates/class_api.rst
Outdated
|
||
.. | ||
Template parameters (if applicable) | ||
Omit template parameters that are just used for specialization/is deduced/ and/or should not be exposed to the user. |
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.
Please change "is deduced" to "are deduced" for subject - verb agreement.
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.
Done!
|
||
.. rubric:: Template Parameters | ||
|
||
:tparam Foo: Description of the Foo template parameter |
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.
Please make "Foo" capitalization consistent with "bar" ...either way is fine.
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.
Here it's just our coding convention of capitalizing template parameters and having parameters/locals lowercase. So the documentation just follows the main core Kokkos coding convention
If you have related info | ||
|
||
.. seealso:: | ||
|
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.
With this, is your idea to link within or among other documentation entries?
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.
Both -- cross referencing works across files. They can even be namespaced which is nice
docs/source/templates/class_api.rst
Outdated
|
||
.. cppkokkos:function:: ~CoolerView() | ||
|
||
Document what special effect the destructor has. |
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 directive, "Document what special ..." is a bit conflict-y with the comment above. A few questions:
- The special effects you mention are in cases apart from the usual business of normal destructor housekeeping ?
- Are there common, canonical examples of special destructor effects? If so, maybe mention some of those to firm up guidance.
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.
See the comment -- special effects include things like releasing resources, etc. I mention in the comments
docs/source/templates/class_api.rst
Outdated
|
||
.. versionchanged:: 3.7.1 | ||
|
||
Only takes one parameter for foo-style operations instead of two. |
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 don't quite understand line 116. Is this phrase in relation to .. versionchanged:: 3.7.1
, or something else? Either way, I don't understand what you're telling me here.
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.
Yes, rst is a little bit annoying to read but if you have a directive (.. directive::
where directive
is the name of the directive). After the two colons are the arguments to the directives, so in this case the version in which it was changed (3.7.1). Some directives have "options" (not this one) and "contents". The "options" and "contents" are tabbed (tabbing is important!) and an empty line must be before the "contents". So in this case the string Only takes one parameter for foo-style operations instead of two.
is the contents of the directive because it's tabbed over one and represents the blurb that gets rendered by sphinx.
Annoyingly, the definition for a comment is similar (there is just no double colon). To make it less confusing it's commonly recommended to put the comment on the next line after the ..
..
This is a comment.
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.
Here is some referenc: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#directives
docs/source/templates/class_api.rst
Outdated
Deprecated types need special handling, both for the badge displayed beforehand and the deprecated version directive. | ||
Note, there is not currently any functionality for other deprecated entities. | ||
|
||
.. cppkokkos:deprecated-type:: 4.0.1 foobar |
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.
In your comment, maybe note key points of our discussion this morning about deprecation syntax in .rst files, and (parser) rendering in html.
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.
Done! Though I did move to the c++ style [[deprecated("reason")]]
|
||
.. | ||
These should only be listed here if they are closely related. E.g. friend operators. However, | ||
something like view_alloc shouldn't be here for view |
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.
Can we readily identify those "friends?" Is there a Sphinx cpp customization to flag "friend" methods, operators, etc.?
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.
No sadly, but at least having them logically grouped in the same documentation makes sense.
something like view_alloc shouldn't be here for view | ||
|
||
.. cppkokkos:function:: template<class ViewSrc> bool operator==(CoolerView, ViewSrc); | ||
|
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.
Is this an actual comparator? i.e., something testing that CoolerView is the same as ViewSrc, or is this just your example of an "allied" or "friend" operator?
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.
Just an example
:tparam ViewDst: the other | ||
|
||
:return: true if :cppkokkos:type:`~View::value_type`, :cppkokkos:type:`~View::array_layout`, :cppkokkos:any:`~View::memory_space`, :cppkokkos:any:`~View::rank`, :cppkokkos:any:`~View::data()` and :cppkokkos:any:`~View::extent` (r), for :code:`0<=r<rank`, match. | ||
|
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.
For lines 146 - 148, a few questions:
- what is
ViewDst
the template parameter for? I don't see it in any near-by functions that use it. - what do the
~
represent in line 148? - is everything in lines 146 - 148 meant to be used in the operator in line 144? I'm having trouble seeing the flow of events : )
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 just an example. I mostly copied it from the view documentation.
The ~
is a typo, it shouldn't be in there, I removed now. These are all supposed to be cross-references, but right now we don't document View as a class so they won't work. Yes, this is all the documentation for the operator.
It may be useful to also have examples for individual functions above. | ||
|
||
Prefer working and compilable examples to prose descriptions (such as "Usage"). | ||
|
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'll check to make sure this code compiles in Compiler Explorer.
docs/source/templates/class_api.rst
Outdated
for free functions that are callable, preserve the naming convention, `view_alloc()` | ||
|
||
``CoolerView`` | ||
===================== |
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.
the length of === should be fixed to match the word otherwise this is misleading since sphinx would raise an exception for this
docs/source/templates/class_api.rst
Outdated
|
||
|
||
Non-Member Functions | ||
---------------------- |
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.
length of ---- should end under s
of Functions
:hidden: | ||
|
||
templates/index | ||
|
||
We are open and try to encourage contributions from external developers. | ||
To do so please first open an issue describing the contribution and then | ||
issue a pull request against the develop branch. |
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.
there is no develop branch, ah nevermind this is for actual code in core
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.
just a few minor ones
4972691
to
b87a5eb
Compare
I don't know why the build is failing but main is not. I haven't touched the failing file (keywords.rst) |
…be found inside of the Contributing page
b87a5eb
to
fd37482
Compare
:language: cppkokkos | ||
|
||
.. | ||
The (pulic header) file the user will include in their code |
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.
The (pulic header) file the user will include in their code | |
The (public header) file the user will include in their code |
Closes #362