-
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
Changes from all commits
3833072
3e6647c
5adf4e2
7a9fafd
c77c4ad
a5e5f81
d5de468
f6ff1ee
fd37482
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Python Virtual Environment | ||
/venv | ||
.venv/ | ||
# PyCharm files | ||
/.idea | ||
# Rendered html files | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,197 @@ | ||||||
.. | ||||||
Use the following convention for headings: | ||||||
|
||||||
# with overline, for parts (collections of chapters) | ||||||
|
||||||
* with overline, for chapters | ||||||
fnrizzi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
= for sections | ||||||
|
||||||
- for subsections | ||||||
|
||||||
^ for subsubsections | ||||||
|
||||||
" for paragraphs | ||||||
|
||||||
.. | ||||||
Class / method / container name) | ||||||
for free functions that are callable, preserve the naming convention, `view_alloc()` | ||||||
|
||||||
``CoolerView`` | ||||||
============== | ||||||
|
||||||
.. role:: cppkokkos(code) | ||||||
: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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Header File: ``Kokkos_Core.hpp`` | ||||||
|
||||||
.. | ||||||
High-level, human-language summary of what the thing does, and if possible, brief statement about why it exists (2 - 3 sentences, max); | ||||||
|
||||||
Description | ||||||
----------- | ||||||
|
||||||
.. | ||||||
The API of the entity. | ||||||
|
||||||
Interface | ||||||
--------- | ||||||
|
||||||
.. | ||||||
The declaration or signature of the entity. | ||||||
|
||||||
.. cppkokkos:class:: template <class DataType, class... Traits> CoolerView | ||||||
|
||||||
.. | ||||||
Template parameters (if applicable) | ||||||
Omit template parameters that are just used for specialization/are deduced/ and/or should not be exposed to the user. | ||||||
|
||||||
.. rubric:: Template Parameters | ||||||
|
||||||
:tparam Foo: Description of the Foo template parameter | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||||||
|
||||||
.. | ||||||
Parameters (if applicable) | ||||||
|
||||||
.. rubric:: Parameters | ||||||
|
||||||
:param bar: Description of the bar parameter | ||||||
|
||||||
.. rubric:: Public Types | ||||||
|
||||||
.. cppkokkos:type:: data_type | ||||||
|
||||||
Some interesting description of the type and how to use it. | ||||||
|
||||||
.. rubric:: Static Public Member Variables | ||||||
|
||||||
.. cppkokkos:member:: int some_var = 5; | ||||||
|
||||||
Description of some_var | ||||||
|
||||||
.. | ||||||
If you have related info | ||||||
|
||||||
.. seealso:: | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||||||
.. | ||||||
We can cross-reference entities | ||||||
|
||||||
The :cppkokkos:func:`frobrnicator` free function. | ||||||
|
||||||
.. rubric:: Constructors | ||||||
|
||||||
.. cppkokkos:function:: CoolerView(CoolerView&& rhs) | ||||||
|
||||||
Whether it's a move/copy/default constructor. Describe what it does. | ||||||
|
||||||
.. | ||||||
Only include the destructor if it does something interesting as part of the API, such as RAII classes that release a resource on their destructor. Classes that merely | ||||||
clean up or destroy their members don't need this member documented. | ||||||
|
||||||
.. rubric:: Destructor | ||||||
|
||||||
.. cppkokkos:function:: ~CoolerView() | ||||||
|
||||||
Performs some special operation when destroyed. | ||||||
|
||||||
.. rubric:: Public Member Functions | ||||||
|
||||||
.. cppkokkos:function:: template<class U> foo(U x) | ||||||
|
||||||
Brief description of the function. | ||||||
|
||||||
:tparam U: Description of U | ||||||
|
||||||
:param: description of x | ||||||
|
||||||
.. | ||||||
Describe any API changes between versions. | ||||||
|
||||||
.. versionchanged:: 3.7.1 | ||||||
|
||||||
What changed between versions: e.g. Only takes one parameter for foo-style operations instead of two. | ||||||
|
||||||
.. | ||||||
Use the C++ syntax for deprecation (don't use the Kokkos deprecated macro) as Sphinx will recognize it. We may in the future | ||||||
add extra parsing after the html is generated to render this more nicely. | ||||||
|
||||||
.. cppkokkos:type:: [[deprecated("in version 4.0.1")]] foobar | ||||||
|
||||||
Represents the foobar capability. | ||||||
|
||||||
.. deprecated:: 4.0.1 | ||||||
|
||||||
Use :cppkokkos:type:`foobat` instead. | ||||||
|
||||||
.. cppkokkos:type:: foobat | ||||||
|
||||||
A better version of foobar. | ||||||
|
||||||
.. versionadded:: 4.0.1 | ||||||
|
||||||
|
||||||
Non-Member Functions | ||||||
-------------------- | ||||||
|
||||||
.. | ||||||
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 commentThe 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 commentThe 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. |
||||||
|
||||||
.. cppkokkos:function:: template<class ViewSrc> bool operator==(CoolerView, ViewSrc); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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:type:`View::memory_space`, :cppkokkos:member:`View::rank`, :cppkokkos:func:`View::data()` and :cppkokkos:expr:`View::extent(r)`, for :cppkokkos:expr:`0<=r<rank`, match. | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For lines 146 - 148, a few questions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
.. cppkokkos:function:: void frobrnicator(CoolerView &v) noexcept | ||||||
|
||||||
:param: v the :cppkokkos:class:`CoolerView` to frobnicate | ||||||
|
||||||
Frobnicates a CoolerView. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
|
||||||
.. | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I'll check to make sure this code compiles in Compiler Explorer. |
||||||
.. code-block:: cpp | ||||||
|
||||||
#include <Kokkos_Core.hpp> | ||||||
#include <cstdio> | ||||||
|
||||||
int main(int argc, char* argv[]) { | ||||||
Kokkos::initialize(argc,argv); | ||||||
|
||||||
int N0 = atoi(argv[1]); | ||||||
int N1 = atoi(argv[2]); | ||||||
|
||||||
Kokkos::View<double*> a("A",N0); | ||||||
Kokkos::View<double*> b("B",N1); | ||||||
|
||||||
Kokkos::parallel_for("InitA", N0, KOKKOS_LAMBDA (const int& i) { | ||||||
a(i) = i; | ||||||
}); | ||||||
|
||||||
Kokkos::parallel_for("InitB", N1, KOKKOS_LAMBDA (const int& i) { | ||||||
b(i) = i; | ||||||
}); | ||||||
|
||||||
Kokkos::View<double**,Kokkos::LayoutLeft> c("C",N0,N1); | ||||||
{ | ||||||
Kokkos::View<const double*> const_a(a); | ||||||
Kokkos::View<const double*> const_b(b); | ||||||
Kokkos::parallel_for("SetC", Kokkos::MDRangePolicy<Kokkos::Rank<2,Kokkos::Iterate::Left>>({0,0},{N0,N1}), | ||||||
KOKKOS_LAMBDA (const int& i0, const int& i1) { | ||||||
c(i0,i1) = a(i0) * b(i1); | ||||||
}); | ||||||
} | ||||||
|
||||||
Kokkos::finalize(); | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Documentation Templates | ||
======================= | ||
|
||
The following documents are templates that may be useful for documenting new API members. For each template, you can see the source by clicking | ||
on the "Edit this page" (pencil button) on the top right corner. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
Class API Template <class_api> |
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