-
Notifications
You must be signed in to change notification settings - Fork 45
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
#166 Custom sphinx directive for deprecating a type alias #172
#166 Custom sphinx directive for deprecating a type alias #172
Conversation
- created cppkokkos based on kokkos - added view_test.rst in order to see how cppkokkos works
- removed `type` word before actual type in html
- supports regex from kokkos releases - added support for changing colors in edit_button_handler - added deprecation type with version to view_test.rst
Hello @crtrott @dalg24 @JBludau @ajpowelsnl @nmm0 @fnrizzi , So, as @nmm0 suggested (thanks for that BTW) I checked the Sphinx extension topic. As it appeared it was not that easy, but doable. In order for this extension to work I created another domain - I called it In order to remove |
this is pretty cool, thanks for the good work. |
Nice, I like how it looks and how easy it is to use! |
@JBludau at the moment we have defined an extra directive |
@marcinwrobel1986 we had an internal discussion a while ago where we basically identified (if I remember correctly, please correct me if I am wrong) that we would want the annotations |
Hello @JBludau ,
So for me now, when we have this extension it shouldn't be a problem to add anything.
I think there is no need for |
@marcinwrobel1986 I remember that we had a later discussion in the documentation session on this, thus this is not the latest info. @ajpowelsnl can you point us to the notes? Does this make sense? |
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.
Looks good -- I just had the one small question about PATH'ing in the docs/source/conf.py
file.
@@ -12,6 +12,7 @@ | |||
# | |||
import os | |||
import sys | |||
sys.path.append(os.path.abspath("./_ext")) | |||
sys.path.insert(0, os.path.abspath('.')) | |||
|
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.
Why are these PATH manipulations necessary, i.e., the sys.path ....
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.
Hello @ajpowelsnl docs/source/conf.py
is a Sphinx config file. In this file one could customize Sphinx behavior. This is a Python file as well, so things defined there go through Python's interpreter.
Line sys.path.append(os.path.abspath("./_ext"))
adds directory _ext
to the path. This is where out extension cppkokkos
is located (_ext/cppkokkos.py
).
Extension is added a few lines below:
extensions = ["myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
"cppkokkos"]
Summarizing: this allows us to use our custom extension cppkokkos
with Sphinx, where new directives are added and other are customized.
I hope that answer your question.
Another (hopefully) simple question: does adding the |
@ajpowelsnl creating a Sphinx extension totally separate us the Sphinx code. OFC when there would be a major update to Sphinx like changing the version from 5.x.x to 6.x.x and we would like to use 6.x.x the extension compatibility must be check before migrating to 6.x.x. Apart from that there is no changes needed in Sphinx codebase or any PR's to Sphinx, which is a huge win. Oh, and thanks for kind words! :) |
@ajpowelsnl what @marcinwrobel1986 is saying is, that if Sphinx changes their public api we need to adapt our extension to it but as long as it stays stable we can update. |
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 hope there is another way ...
@@ -0,0 +1,7869 @@ | |||
"""The C++ language 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.
Where did this come from and why would we need to copy it ... is this their way of adding extensions? This will be bad ...
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.
Furthermore, this is not reviewable ... 7k line change
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.
@JBludau I took C++ domain and changed it to cppkokkos
domain. This is adding stuff and changed behavior of existing stuff. This was the only way to do that. I don't expect anyone to review that extension.
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 this case could you post a diff so we can see what you added?
If we stick with the copy we would need to invest this effort every time the original is updated ... do you know how stable it is?
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.
@JBludau I will post a diff tomorrow morning CET.
I will check tomorrow as well compatibility with latest Sphinx. We use 5.0.1 (was the last version when we started our work) and the latest is 5.3
IMHO in Sphinx nomenclature this is just a Domain
and it should not change in the future, maybe it could in case of some bugs. But it does not have to do much/anything with the Sphinx core.
The story is that I don't like duplicate code especially nearly 8k lines, but that was the only way we have a domain which works like C++ domain, but is customizable. One can not register twice domain or lexer with the same name. CppLexer is imported (not modified in any way), so here we will always be up to date. Back to the story I started slowly with smaller pieces, but I quickly figure out I need all of it.
Summarizing CPPKokkosDomain
inherits from Sphinx's Domain
, so in worst case scenario they could change the API in Sphinx 6.x.x, but I really doubt they will, because it would mean they have to change all the domains defined in Sphinx package + all user(customers) defined domains would need to be changed.
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.
guess we are kind of stuck with copying the 7k lines then ...
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 OFC option to reinvent the wheel :)
@JBludau I attached the diff here. |
@JBludau I can also confirn, that the extension works perfectly well with Sphinx 5.3 |
@JBludau regarding maintainability concerns, we can use this version of Sphinx and never upgrade. Python 3.10 end of life is set to 04 Oct 2026. IMHO the extension will not need any maintenance. |
Update
|
THIS PR:
cppkokkos
extension to SphinxSphinx
domain -cppkokkos
CppLexer
as default lexer forcppkokkos
domaindeprecated-type
directive tocppkokkos
domain with[DEPRECATED]
in frontdeprecated-type
,[DEPRECATED since 3.6.01]
type
in front of the defined type in Sphinx extensionTest page look:
The
*.rst
syntax: