Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

""" 

@file 

@brief Automated link to documentation. 

""" 

 

 

def python_link_doc(m, o=None, format="rst"): 

""" 

Returns a url about :epkg:`Python` documentation. 

 

.. runpython:: 

:showcode: 

 

from pyquickhelper.sphinxext import python_link_doc 

print(python_link_doc("io")) 

 

@param m Python module 

@param o function name or class name 

@param format 'rst' or 'raw' 

@return str or tuple 

""" 

if format == "raw": 

if o is None: 

return m, "https://docs.python.org/3/library/{0}.html".format(m) 

else: 

return "{0}.{1}".format(m, o), "https://docs.python.org/3/library/{0}.html{0}.{1}".format(m, o) 

elif format == "rst": 

name, url = python_link_doc(m, o, format="raw") 

return "`{0} <{1}>`_".format(name, url) 

else: 

raise ValueError("Unexpected format '{0}'".format(format))