我想使用docstring或類似的東西來記錄我的fortran例程,這些例程可以與python幫助命令一起使用。由f2py創建的自動生成的文檔字符串是非常不夠的,我需要添加更多的細節,就像我們用python函數docstring一樣。 在我的想法,它應該看起來像: mymod.f: subroutine foo()
! This is my function
end subroutine
我有開始這樣的功能: def apply_weighting(self, weighting):
"""
Available functions: {}
""".format(weightings)
我想是的文檔字符串打印的可用加權函數的字典。但是在檢查功能時指出沒有可用的文檔字符串: In [69]: d.apply_weighting?
Type: ins
我有很多的功能類型的Python: def foobar(one, two):
"""
My function.
:param int one: My one argument.
:param int two: My two argument.
:rtype: Something nice.
"""
return 100 + o
我在用於配置Docopt的文檔字符串中有幾個詳細的選項規範。有些項目相當長。有沒有一種方法可以使文本更清晰易讀,或者更容易使它適合線寬? 比方說,在文檔字符串文本的相關位如下: Usage:
program [options]
Options:
-h, --help Show this help message.
-c, --configuration=
爲字典參數添加文檔字符串的建議方式是什麼?我可以看到多行DOC文本字符串示例here。 我需要將輸入參數記錄到文檔字符串中的函數。如果它是一個簡單的變量,我可以使用類似: def func2(a=x, b = y):
""" fun2 takes two integers
Keyword arguments:
a -- refers to age (default 18)
b -- re