python-sphinx

Sphinx: Multiple (Nested) Roles

懵懂的女人 提交于 2020-01-16 17:05:00
问题 in my Sphinx docs I would like to create a glossary, potentially containing :math: , or other roles: .. glossary:: :math:`f(x)` Description Is there any way to reference this entry with a text that has the same style as the glossary entry? :term:`f(x)` Works, but is rendered as a plain hyperlink. I want a hyperlink with the original styling instead: :term:`:math:`f(x)`` Does not work. :term:`:math:`f(x)` <f(x)>` Also doesnt. Many thanks for the help. 来源: https://stackoverflow.com/questions

Sphinx: Multiple (Nested) Roles

一世执手 提交于 2020-01-16 17:03:08
问题 in my Sphinx docs I would like to create a glossary, potentially containing :math: , or other roles: .. glossary:: :math:`f(x)` Description Is there any way to reference this entry with a text that has the same style as the glossary entry? :term:`f(x)` Works, but is rendered as a plain hyperlink. I want a hyperlink with the original styling instead: :term:`:math:`f(x)`` Does not work. :term:`:math:`f(x)` <f(x)>` Also doesnt. Many thanks for the help. 来源: https://stackoverflow.com/questions

Making Sphinx format the Markdown code examples in Python docstrings

好久不见. 提交于 2020-01-16 13:20:16
问题 I'm trying to use Sphinx to auto-generate API documentation for a Python library, and I can't make it properly format the example code snippets in the docstrings - they do get indented but lines of the same indentation get concatenated (https://weka-io.github.io/easypy) I understand that the problem is that the format I'm using to mark the code blocks is Markdown (indent them by 4 spaces) but Sphinx is expecting reStructuredText ( code-block:: ) I've tried googling for a solution and it

How to document callable class with Sphinx?

房东的猫 提交于 2020-01-16 09:39:29
问题 I have a callable class with @dataclass annotation. I want to document it the way, so in the documentation, people can distinguish difference between __call__ and __init__ methods. Since I am using @dataclass __init__ is automatically generated. Example of the code in my case: @final @dataclass(frozen=True, slots=True) class Casting(object): """Cast one type of code to another. Constructor arguments: :param int_converter_function: function to convert to int :param float_converter_function:

How to freeze the first column and first row in Sphinx

折月煮酒 提交于 2020-01-15 09:42:28
问题 I'm new at working with Sphinx and I know thats Phynx is not predestined for tables but I would like to use it for a documentaion of our survey instruments. Therefore I created a table with different topics that are asked in our questionnaires. Since our survey started in 1984, we have a lot of years to cover. The table looks like this: The years (rows) go on until the recent year and it's going to grow every year When I use the table (in csv format) in Sphynx it doesn't show the whole table,

Sphinx Docs not importing Django project settings

ぃ、小莉子 提交于 2020-01-15 05:26:30
问题 I just recently move a Django project into a new virtualenv. The project works fine, but I am having trouble building my Sphinx Documentation. in my conf.py I have this: import sys, os sys.path.append('/path/to/myproject') from django.core.management import setup_environ from myproject import settings setup_environ(settings) But when I use make html I get this error: from myproject import settings ImportError: No module named myproject Any help much appreciated. 回答1: Turns out the conf.py

Overriding Sphinx autodoc “Alias of” for import of private class?

泪湿孤枕 提交于 2020-01-14 07:24:14
问题 I have a Python package that I am attempting to document with sphinx-autodoc. My python package has an __init__.py file that imports a class out from a submodule to make it accessible at the package level. from a.b.c.d import _Foo as Foo __all__ = ["Foo"] If I do this, my (html) documentation is as follows: a.b.c package Submodules a.b.c.d module [snip documentation of irrelevant public classes within the a.b.c.d module] Module contents The c module. a.b.c. Foo alias of _Foo Not super useful

How to make an internal link to a heading in sphinx restructuredtext without creating arbitrary labels?

故事扮演 提交于 2020-01-12 04:20:09
问题 I have a document with many headings and sub-headings. Further into the text I want to link back to one of the headings. How can I do this without the redundancy of :ref: labels? The contents seems to pick up headers just fine. I was hoping for something like this: `#polled-data-retrieval`_ . 回答1: reStructuredText supports implicit hyperlink targets. From the reStructuredText quick reference: Section titles, footnotes, and citations automatically generate hyperlink targets (the title text or

Sphinx docs: Remove blank pages from generated PDFs?

江枫思渺然 提交于 2020-01-11 15:13:32
问题 By default, Sphinx documentation outputs a PDF that's formatted for duplex printing. So there is a blank page between the title page and the TOC, the TOC and the introduction, the introduction and the first section, etc. My users are always going to look at the PDF online. So I would like to remove these blank pages. This seems to be a vexed issue in Sphinx. See this email thread. This user suggests two solutions, but neither work for me. Curiously, the first solution: latex_elements = {

Preserve default arguments of wrapped/decorated Python function in Sphinx documentation

♀尐吖头ヾ 提交于 2020-01-11 02:10:29
问题 How can I replace *args and **kwargs with the real signature in the documentation of decorated functions? Let's say I have the following decorator and decorated function: import functools def mywrapper(func): @functools.wraps(func) def new_func(*args, **kwargs): print('Wrapping Ho!') return func(*args, **kwargs) return new_func @mywrapper def myfunc(foo=42, bar=43): """Obscure Addition :param foo: bar! :param bar: bla bla :return: foo + bar """ return foo + bar Accordingly, calling print