难道真的没有比 POD 更好的记录 Perl 代码的方法了吗?
我已经是一名 Perl 程序员很长时间了,但我总是对 POD 中的文档有疑问。
当我在代码中使用POD注释时,代码很难阅读。当我在文件末尾使用 POD 注释时,存在文档与代码不同步的危险。
我怀念类似于 Java 的文档风格。
/**
* @description
* ...
*/
我寻找一种更简单、更直观的文档风格。有这样的事吗?
I'm a Perl programmer for a long time, but I always have problems with documentation in POD.
When I use POD comments in the code, the code is difficult to read. When I use POD comments at the end of file, there is the danger that the documentation is not in sync with the code.
I miss a documentation style similar to Java.
/**
* @description
* ...
*/
I look for an easier and more intuitive documentation style. Is there such a thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
快速搜索发现 Doxygen Filter 声称允许您使用 Doxygen 风格的注释(非常接近 Javadoc)来记录 Perl 代码。
A quick search found Doxygen Filter which purports to allow you to use Doxygen style comments (which are very close to Javadoc) to document Perl code.
好吧,POD 是发布 Perl 文档的公认标准。
我确实发现维护起来也很烦人;我最近尝试使用 Pod::Weaver 来维护文档并构建它发布时进入 Pod。这有点棘手,因为它在过滤和构建 POD 方面非常灵活,并且可以使用更多的文档(在 POD 或其他方式中)。但看起来很有希望。对于我来说,给出更多的判断还为时过早,但它似乎很有希望。
希望这有帮助
Well, POD's the accepted standard for publishing Perl documentation.
I do find it rather annoying to maintain as well; I've recently experimented with using Pod::Weaver to maintain the documentation and build it into Pod on release. It's a little bit tricky in that it's quite flexible in how you filter and build the POD, and could do with a little more documentation (in POD or otherwise). But seems promising. Still too early for me to give more of a judgement than that, but it seems promising.
Hope this helps
为什么你觉得代码用 Pod 很难读懂?该代码与周围的其他代码相比是否难以阅读?也许您在代码的特定部分投入了太多内容,而不是编写小方法等。您确定不是您的代码难以阅读吗?
您不必将所有文档放在代码末尾。 Pod 非常适合内联代码,允许您将子例程或方法的文档放在子例程或方法旁边。
Pod 还存在其他问题吗?
Why do you think the code is hard to read with Pod? Is the code hard to read with other code around it? Perhaps you're putting too much into a particular part of the code, instead of writing small methods, etc. Are you sure it's not your code that's hard to read?
You don't have to put all of your documentation at the end of the code. Pod is perfectly fine inline with code, allowing you to put the documentation for a subroutine or method right next to the subroutine or method.
Is there some other problem you have with Pod?
我唯一一次遇到 POD 的问题是在使用文本编辑器无法正确突出显示它。
就像Java中的一切这个 似乎过于冗长:
与等效的 Perl 相比。
The only time I have had a problem with POD is when using a text editor that doesn't highlight it correctly.
Just like everything in Java this seems overly verbose:
When compared to the equivalent Perl.
您可能想看看 Rinci。使用此功能的应用程序示例:File::RsyBak、Git::Bunch, App::OrgUtils。
以下是记录模块的方法。您在模块中声明 %SPEC 并将文档放入其中。每个函数都有自己的密钥。有预定义字段。支持本地化。格式化是在 Markdown 中完成的。一个例子:
它没有使用 Java 或 Perl 5 风格的“注释”中放置文档,而是使用程序直接可用的数据结构。 (请注意,Perl 6 也在走这条路。)将其视为疯狂的(或结构化的)Python 文档字符串。
有一些工具可以从元数据(规范)生成 POD、文本、HTML。除了文档之外,元数据对于其他事情也很有用,例如参数验证、命令行界面等。
披露:我是开发人员。
You might want to take a look at Rinci. Examples of applications which use this: File::RsyBak, Git::Bunch, App::OrgUtils.
Here's how you document modules. You declare %SPEC in your module and put documentation inside it. Each function gets its own key. There are predefined fields. Localization is supported. The formatting is done in Markdown. An example:
Instead of using Java- or Perl 5 style of putting documentation in "comments", it uses data structure directly available to the programs. (Note that Perl 6 is also going this way.) Think of it as Python docstring gone crazy (or structured).
There are tools to generate POD, text, HTML from the metadata (spec). Aside from documentation, the metadata is also useful for other things like argument validation, command-line interface, etc.
Disclosure: I'm the developer.
我自己经常发现想要将代码条目复制到文档中。
还没有找到如何欺骗 POD 在 pod 时读取代码,同时让代码在解析时执行。
我真的必须满足于此吗:
话又说回来,大多数语言都需要双重打字来记录。
Myself, I often find wanting to reproduce code entries to documentation.
Yet to find how I can trick POD to read the code when podding whilst letting the code execute whilst parsing.
Do I really have to settle for this:
Then again, most languages require the double typing to document.