NumpyDoc:标签页如何解析?

问题描述 投票:1回答:1

[我正在使用Spyder IDE(在Mac OS上为v.2.1.11)并编写一些代码,并且在为函数编写DocString(NumpyDoc格式)时,无法弄清为什么Spyder Object Inspector] >以这种奇怪的方式格式化缩进线。

对于像下面这样的文档字符串,“ sellmeier计算出...]之后的论文参考文献> [[缩进

,这会导致奇怪的行为:def AlInGaAs(x, wl): ''' Returns the refractive index of ~Al(x)Ga(1-x)In(1-x-y)As (lattice-matched to InP) at the specified wavelength, wl (in microns) and Aluminum content (x=0.0-1.0). For lattice-matching, the actual mole ratio, x, is defined as so: InP-matched X: (Al48 In52 As)_X --> (Ga47 In53 As)_1-X Valid for wavelengths: 0.900 - 2.100 um & x: 0.3 - 1.0 Calc'd by sellmeier equation, with params from M. J. Mondry, D. I. Babic, J. E. Bowers, and L. A. Coldren, "Refractive indexes of (Al,Ga,In)As epilayers on InP for optoelectronic applications," Phot. Tech. Lett., vol. 4, no. 6, pp. 627-630, 1992 Parameters ---------- x: float Mole ratio of Al, as in: Al(x) Ga(1-x) In(1-x-y) As. Also varies In slightly for lattice-matching. wl: float wavelength in microns. ... '''
上面的DocString产生以下输出(Spyder“对象检查器” /帮助面板的屏幕快照),在“ 

MJ Mondry,DI Babic ...]上具有意外的bolding

和缩进/列表号。 >“文字:
“奇怪的缩进和参考书的清单。<p同时删除缩进:

def AlInGaAs(x, wl): ''' Returns the refractive index of ~Al(x)Ga(1-x)In(1-x-y)As (lattice-matched to InP) at the specified wavelength, wl (in microns) and Aluminum content (x=0.0-1.0). For lattice-matching, the actual mole ratio, x, is defined as so: InP-matched X: (Al48 In52 As)_X --> (Ga47 In53 As)_1-X Valid for wavelengths: 0.900 - 2.100 um & x: 0.3 - 1.0 Calc'd by sellmeier equation, with params from *** INDENT REMOVED BELOW *** M. J. Mondry, D. I. Babic, J. E. Bowers, and L. A. Coldren, "Refractive indexes of (Al,Ga,In)As epilayers on InP for optoelectronic applications," Phot. Tech. Lett., vol. 4, no. 6, pp. 627-630, 1992 Parameters ---------- x: float Mole ratio of Al, as in: Al(x) Ga(1-x) In(1-x-y) As. Also varies In slightly for lattice-matching. wl: float wavelength in microns. ... '''

看起来很正常:这仅仅是Spyder中的错误,还是缩进的其他预期用途?在Spyder IDE(我认为是NumpyDoc格式)中,应该如何使用(或不使用)缩进来产生各种类型的格式?NumpyDoc Documentation Page上没有任何关于缩进和自动列表的讨论。

只是想知道是否有一些有用的未记录的DocString功能,我可以在这里利用它。(另一方面,我确实注意到我可以使用DocString中的“ References”部分,有时我会将Ref移入该部分。)

谢谢!

我的版本如下:Spyder v2.1.11,达尔文(Darwin)上的Python 2.7.6,Qt 4.8.4,PyQt4(API v2)4.9.6,Mac OS 10.10.2

我正在使用Spyder IDE(在Mac OS上为v.2.1.11)并编写一些代码,并且在为函数编写DocString(NumpyDoc格式)时,无法弄清楚为什么Spyder Object Inspector格式化缩进格式...

((
Spyder dev here)我已经设法通过重新格式化文档字符串来获得想要的(我认为)

def AlInGaAs(x, wl): ''' Returns the refractive index of ~Al(x)Ga(1-x)In(1-x-y)As (lattice-matched to InP) at the specified wavelength, wl (in microns) and Aluminum content (x=0.0-1.0). For lattice-matching, the actual mole ratio, x, is defined as so: InP-matched X: (Al48 In52 As)_X --> (Ga47 In53 As)_1-X Valid for wavelengths: 0.900 - 2.100 um & x: 0.3 - 1.0 Calculated by sellmeier equation, with params from M. J. Mondry, D. I. Babic, J. E. Bowers, and L. A. Coldren, "Refractive indexes of (Al,Ga,In)As epilayers on InP for optoelectronic applications," Phot. Tech. Lett., vol. 4, no. 6, pp. 627-630, 1992 Parameters ---------- x: float Mole ratio of Al, as in: Al(x) Ga(1-x) In(1-x-y) As. Also varies In slightly for lattice-matching. wl: float wavelength in microns. '''

我唯一要做的就是在79列上打破你的(很长)行。也许这是Sphinx(我们用来渲染文档字符串的库)的局限性。

:Spyder 2.1.11很古老!!请尝试更新到我们的最新版本2.3.4。
python spyder docstring numpydoc
1个回答
0
投票
Spyder dev here)我已经设法通过重新格式化文档字符串来获得想要的(我认为)

def AlInGaAs(x, wl): ''' Returns the refractive index of ~Al(x)Ga(1-x)In(1-x-y)As (lattice-matched to InP) at the specified wavelength, wl (in microns) and Aluminum content (x=0.0-1.0). For lattice-matching, the actual mole ratio, x, is defined as so: InP-matched X: (Al48 In52 As)_X --> (Ga47 In53 As)_1-X Valid for wavelengths: 0.900 - 2.100 um & x: 0.3 - 1.0 Calculated by sellmeier equation, with params from M. J. Mondry, D. I. Babic, J. E. Bowers, and L. A. Coldren, "Refractive indexes of (Al,Ga,In)As epilayers on InP for optoelectronic applications," Phot. Tech. Lett., vol. 4, no. 6, pp. 627-630, 1992 Parameters ---------- x: float Mole ratio of Al, as in: Al(x) Ga(1-x) In(1-x-y) As. Also varies In slightly for lattice-matching. wl: float wavelength in microns. '''

© www.soinside.com 2019 - 2024. All rights reserved.