How could the end user access the generated Sphinx documentation for the Python package?

I developed the package in python and I created documentation for it using Sphinx.

The corresponding part of the folder structure is shown below:

my_package
  setup.py
  my_package
    my_module.py
  docs
    index.rst
    _build
      html
        index.html

The package will be placed in a specific location on the local network to which it refers PYTHONPATH. My end user will only be able to access my package with import my_package. They did not know where the documentation was (or the package for that matter). Use help(my_package)will only show the user the documentation inside the module.

, , index.html? , html , . ?

+4
3

, . , pandas ( .rst) Github, URL.

0

@pkqxdd-s:

my_package

# my_module.py

def get_docs_index_path():
    import os
    my_package_root = os.path.dirname(os.path.dirname(__file__))
    docs_index = os.path.join(my_package_root, 'docs', '_build', 'html', 'index.html')
    return docs_index

my_module my_package docstring, , help(my_module), -

... 
# original my_module docstring
...

See sphinx docs at <path to your index>

, , get_docs_index_path() docstring.

+1

, , , , , your_module.__file__ (. ), , os.path. , os.path.dirname(your_module.__file__) , docs. .html.

0

Source: https://habr.com/ru/post/1673692/


All Articles