0

I am preparing documents for a python package (let's call it pack). Sometimes I need to refere to a module or class of the package like `pack.My_Class.my_module` using back tick and I want to add a hyper link to the module documentation.

In the output the referenced text become italic and no link is created. I have checked cross reference documents of sphinx and also know how to refer to a section in the rst file.

.. _references:

References
-----------

look at :ref:`text to explain <references>`

Edit: In index.rst file :

    .. automodule:: pack.examples.scripts.example1

in example1.py file I have the documents:

    """
    This is a test to refere to a function.
    :func:`pack.utility.order_parameter`
    """

The files are distributed like this:

    pack/
        __init__.py
        utility.py
        examples/
            example1.py

    docs/
        make.bat
        makefile
        source/
            config.py
            index.rst
        build/
            html/

the conf.py is like this:

    import os
    import sys
    sys.path.insert(0, os.path.abspath('../../pack'))
    project = 'pack'
    release = '0.1'
    extensions = ['sphinx.ext.todo',
                  'sphinx.ext.viewcode',
                  'sphinx.ext.autodoc',
                  'sphinx.ext.githubpages',
                  'sphinx.ext.inheritance_diagram',
                  'sphinx.ext.coverage',
                  'sphinx.ext.napoleon',
                  'sphinx.ext.imgmath',
                  'sphinx.ext.mathjax',
                  ]
    templates_path = ['_templates']
    exclude_patterns = ['_build']
    master_doc = 'index'
    html_theme = 'nature'
    html_static_path = ['_static']
    latex_elements = {
        'papersize': 'letterpaper',
        'pointsize': '12pt',
        'preamble': r"""
    \usepackage{setspace}
    """
    }
    numfig = True
Abolfazl
  • 1,047
  • 2
  • 12
  • 29
  • Is this what you are looking for? https://stackoverflow.com/q/22700606/407651 – mzjn Aug 13 '21 at 13:06
  • Yeah this is what I am looking for, but I probably missing something because no hyperlink is created. I use :func:\`pack.utility.order_parameter\` and it represented as **pack.utility.order_parameter()**. – Abolfazl Aug 14 '21 at 14:03
  • More information is needed. Can you create a [mcve]? – mzjn Aug 14 '21 at 14:10
  • I hope made it more clear. please let me know if it still nee clarification. – Abolfazl Aug 14 '21 at 14:48
  • Is there no `automodule` for the utility.py module? If there isn't, there is no target for :func:`pack.utility.order_parameter`. – mzjn Aug 14 '21 at 15:32

0 Answers0