1

我正在为一些 Python 代码编写文档,但无法正确插入注释。我在 .rst 文件中写入的内容与生成的 html 中显示的内容之间存在问题。它看起来像这样:

.rst 文件:

.. sourcecode:: python  

    class Foo( argument_1, argument_2 ):           # argument_1 is blabla, arg2 is..

        def bar():                                 # method bar does ...
            print 'foo'                            # another comment

        def foo_bar():                             # foo_bar method explanation
            print 'foo_bar body'                   # ....

在生成的 .html 文件中,它看起来很好,只是注释未对齐:

.html 文件:

class Foo( argument_1, argument_2 ):         # argument_1 is blabla, arg2 is..

    def bar():                                  # method bar does ...
        print 'foo'                            # another comment

    def foo_bar():                             # foo_bar method explanation
        print 'foo_bar body'                 # ....

有没有办法解决这个问题?我在 Ubuntu 11.04 上使用 gedit 来编写这个文档。我一直在使用制表符的宽度,用空格替换制表符,但这没有帮助。

4

0 回答 0