记录perl代码真的没有比POD更好的方法吗?

我很长一段时间都是Perl程序员,但我在POD中的文档总是有问题。 当我在代码中使用POD注释时,代码很难阅读。当我在文件末尾使用POD注释时,存在文档与代码不同步的危险。 我想念一个类似于Java的文档样式。
/**
 * @description
 * ...
 */
我寻找更简单,更直观的文档样式。有这样的事吗?     
已邀请:
快速搜索发现Doxygen Filter声称允许您使用Doxygen样式注释(非常接近Javadoc)来记录Perl代码。     
那么,POD是发布Perl文档的公认标准。 我觉得维护也很烦人;我最近尝试使用Pod :: Weaver来维护文档并在发布时将其构建到Pod中。这有点棘手,因为它在过滤和构建POD方面非常灵活,并且可以使用更多文档(在POD或其他方面)。但似乎很有希望。对我来说,提供更多的判断还为时尚早,但似乎很有希望。 希望这可以帮助     
为什么你认为使用Pod难以阅读代码?代码难以与周围的其他代码一起阅读吗?也许你在代码的某个特定部分投入太多,而不是编写小方法等等。你确定你的代码不是很难读的吗? 您不必将所有文档放在代码的末尾。 Pod与代码完全一致,允许您将子例程或方法的文档放在子例程或方法旁边。 你有什么其他问题与Pod?     
我唯一遇到POD问题的时候是使用没有正确突出显示它的文本编辑器。 就像Java中的所有东西一样,这似乎过于冗长:
/**
 * Returns an Image object that can then be painted on the screen. 
 * The url argument must specify an absolute  

{@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 *  

@param  url  an absolute URL giving the base location of the image
 *  

@param  name the location of the image, relative to the url argument
 *  

@return      the image at the specified URL
 *  

@see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }
与等效的Perl相比。
=item getImage( url, name )

This method always returns immediately, whether or not the 
image exists. When this applet attempts to draw the image on
the screen, the data will be loaded. The graphics primitives 
that draw the image will incrementally paint on the screen. 

url must be an absolute URL giving the base location of the image

name is the location of the image, relative to the url argument

=cut

sub getImage{
  my ($url,$name) = @_;

  ...
}
    
你可能想看看Rinci。使用它的应用程序示例:File :: RsyBak,Git :: Bunch,App :: OrgUtils。 这是您记录模块的方式。您在模块中声明%SPEC并将文档放入其中。每个函数都有自己的密钥。有预定义的字段。支持本地化。格式化在Markdown中完成。一个例子:
$SPEC{':package'} = {
    summary => 'Module to do foo',
    "summary.alt.lang.id_ID" => "Modul untuk melakukan foo",
    description => <<EOT,
Blah...
...
EOT
    links => [...],
};
$SPEC{func1} = {
    summary => '...',
    description => '...',
    args => {
        arg1 => {
            schema => ...,
            summary => ....,
            description => ...,
        },
    },
    examples => [...],
    links => [...],
    ...
};
它使用直接可用于程序的数据结构,而不是在“注释”中使用Java或Perl 5样式的文档。 (注意Perl 6也是这样的。)把它想象成Python文档字符串变得疯狂(或结构化)。 有一些工具可以从元数据(规范)生成POD,文本,HTML。除了文档之外,元数据还可用于其他参数,如参数验证,命令行界面等。 披露:我是开发人员。     
我自己经常发现想要将代码条目重现为文档。 然而,找到我如何欺骗POD在播放时读取代码,同时让代码在解析时执行。 我真的要满足于此:
=head1 Variables

use vars (%V &C)

=cut

use vars (%V %C)

=head2 Constants

$C{hashConstant1} = "/path/to/file"

=cut

$C{hashConstant1} = "/path/to/file";

=head2 Variables

$V{strVar1} = undef

=cut

$V{strVar1} = undef;
然后,大多数语言都需要双重输入才能记录。     

要回复问题请先登录注册