-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PyFunction and PyVariable; directives for python functions and va…
…riables
- Loading branch information
Showing
4 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -410,6 +410,13 @@ class PyModulelevel(PyObject): | |
Description of an object on module level (functions, data). | ||
""" | ||
|
||
def run(self): | ||
# type: () -> List[nodes.Node] | ||
warnings.warn('PyClassmember is deprecated.', | ||
RemovedInSphinx40Warning) | ||
|
||
return super().run() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tk0miya
Author
Member
|
||
|
||
def needs_arglist(self): | ||
# type: () -> bool | ||
return self.objtype == 'function' | ||
|
@@ -428,6 +435,34 @@ def get_index_text(self, modname, name_cls): | |
return '' | ||
|
||
|
||
class PyFunction(PyObject): | ||
"""Description of a function.""" | ||
|
||
def needs_arglist(self): | ||
# type: () -> bool | ||
return True | ||
|
||
def get_index_text(self, modname, name_cls): | ||
# type: (str, Tuple[str, str]) -> str | ||
name, cls = name_cls | ||
if modname: | ||
return _('%s() (in module %s)') % (name, modname) | ||
else: | ||
return _('%s() (built-in function)') % name | ||
|
||
|
||
class PyVariable(PyObject): | ||
"""Description of a variable.""" | ||
|
||
def get_index_text(self, modname, name_cls): | ||
# type: (str, Tuple[str, str]) -> str | ||
name, cls = name_cls | ||
if modname: | ||
return _('%s (in module %s)') % (name, modname) | ||
else: | ||
return _('%s (built-in variable)') % name | ||
|
||
|
||
class PyClasslike(PyObject): | ||
""" | ||
Description of a class-like object (classes, interfaces, exceptions). | ||
|
@@ -839,8 +874,8 @@ class PythonDomain(Domain): | |
} # type: Dict[str, ObjType] | ||
|
||
directives = { | ||
'function': PyModulelevel, | ||
'data': PyModulelevel, | ||
'function': PyFunction, | ||
'data': PyVariable, | ||
'class': PyClasslike, | ||
'exception': PyClasslike, | ||
'method': PyMethod, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tk0miya
I'm a bit confused about this warning. which is on PyModulelevel - and there is the same on PyClassmember (
sphinx/sphinx/domains/python.py
Lines 542 to 544 in 4633ab9
Given the commit it should say "PyModulelevel" probably?
But it/they should also have a stacklevel probably?