Coverage for python3_module_template/subproject2/myexample2.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-03 02:15 +0200

1""" 

2@file 

3@brief This the documentation of this module (myexample2). 

4 

5To make a reference to a blog post, just read :ref:`label-to-this-blogpost`. 

6 

7The following documentation comes from a directive 

8`runpython 

9<http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/pyquickhelper/helpgen/sphinx_runpython_extension.html>`_ 

10which outputs documentation on the standard output:: 

11 

12 .. runpython:: 

13 :showcode: 

14 

15 for l in range(0,10): 

16 print(" line", l) 

17 

18Which gives: 

19 

20.. runpython:: 

21 :showcode: 

22 

23 for l in range(0,10): 

24 print(" line", l) 

25 

26And without the input code: 

27 

28.. runpython:: 

29 

30 for l in range(0,10): 

31 print(" line", l) 

32 

33You can also add option *rst*:: 

34 

35 .. runpython:: 

36 :rst: 

37 

38 for l in range(0,10): 

39 print("**line**", "*" +str(l)+"*") 

40 print('') 

41 

42Which displays interpreted RST: 

43 

44.. runpython:: 

45 :rst: 

46 

47 for l in range(0,10): 

48 print("**line**", "*" +str(l)+"*") 

49 print('') 

50 

51It can be run in a separate process with option ``:process:`` 

52(click on source): 

53 

54.. runpython:: 

55 :process: 

56 

57 import python3_module_template 

58 import os 

59 print(os.path.split(python3_module_template.__file__)[-1]) 

60""" 

61from ..subproject.myexample import myclass 

62 

63 

64class myclass2(myclass): 

65 

66 """ 

67 This is the documentation for this class. 

68 

69 @var pa an example of an attribute. 

70 

71 Inline :math:`x^2 + y + z`. Another equation to test: 

72 

73 .. math:: 

74 

75 x^2 + y 

76 

77 .. math:: 

78 

79 \\sum_{i=1}^n x^2 

80 

81 """ 

82 

83 def __init__(self, pa): 

84 """ 

85 @param pa first parameter 

86 """ 

87 myclass.__init__(self, pa) 

88 

89 def get_value(self, mul): 

90 """ 

91 returns the parameter multiplied by a value 

92 @param mul a float 

93 @return a float 

94 """ 

95 return self.pa * mul 

96 

97 @staticmethod 

98 def static_example(): 

99 """ 

100 @return a boolean 

101 """ 

102 return True 

103 

104 @property 

105 def property_example(self): 

106 """ 

107 a property example 

108 """ 

109 return True