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@file 

3@brief Automated link to documentation. 

4""" 

5 

6 

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

8 """ 

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

10 

11 .. runpython:: 

12 :showcode: 

13 

14 from pyquickhelper.sphinxext import python_link_doc 

15 print(python_link_doc("io")) 

16 

17 @param m Python module 

18 @param o function name or class name 

19 @param format 'rst' or 'raw' 

20 @return str or tuple 

21 """ 

22 if format == "raw": 

23 if o is None: 

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

25 return ("{0}.{1}".format(m, o), 

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

27 if format == "rst": 

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

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

30 raise ValueError( # pragma: no cover 

31 "Unexpected format '{0}'".format(format))