如何注释重构文本中的字符串?
HTML的注释是,如何用重组文本制作这个注释块?换句话说,如何注释掉重组文本中的某些行?
The comment of HTML is <!-- .. -->
, how can I make this comment block with restructured text? In order words, how can I comment out some of the lines in restructured text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
来自参考:
也可以将注释放在与双点相同的行上:
但这被认为是不好的做法,因为如果注释与正确的标记结构匹配,则可能会导致意想不到的后果,正如 @CecilCurry 在 下面的评论。
From the reference:
It is also possible to put the comment on the same line as the double dots:
This is however considered bad practice since it may lead to unintended consequences if the comment matches a proper markup construct, as pointed out by @CecilCurry in the comment below.
对于注释,请添加 2 个句点
..
,后跟换行符,然后缩进您的注释。例子:
For comments, add 2 periods
..
followed by a newline and then your comment indented.Example:
请原谅这个重复的答案,因为我正在努力帮助像我这样的 RST 新手。我的回答显示了评论的上下文。
我天真地尝试使用上面的答案在我的 RST 文档中标记一行,不要这样做:
Sphinx(或其他 RST 格式化程序)不会抱怨,但“大家好”将出现在输出中。相反,在评论之前和之后放置一个空行,如下所示:
但这样做的缺点是该段落结束然后重新开始,因此段落之间会有空格。
我没有在 RST 中找到任何可以使某些文本完全消失的 C
/* */
或 HTML注释语法的等效项。
Please forgive this duplicative answer cos I'm trying to help RST newbies like me. My answer shows the CONTEXT of a comment.
I naively tried marking a line in my RST document using the answer above, DO NOT DO THIS:
Sphinx (or other RST formatter) will not complain, but "hi everyone" will appear in the output. Instead place a blank line before and after your comment like this:
But the downside of this is that the paragraph is ended then restarted, so you will have whitespace between.
I have not found any equivalent in RST for the C
/* */
or HTML<!-- -->
comment syntax that can make some text vanish totally.我遇到了这个线程,寻找一种更明确的方式在重构文本中放置注释。就我个人而言,我当然也不喜欢单行
..这是一条评论
。为了保持评论可搜索和可识别,我建议考虑使用记录( http://www.sphinx-doc.org/en/master/usage/restructedtext/directives.html):“未定义的标签是错误的”,例如
comment< /代码>。
或者,可以以 todo,允许语法,例如
在没有此类扩展的情况下这样做当然会给出来自构建器的错误消息。但是有了这样的扩展,就像todo一样,就可以从文档中提取注释列表。
I came across this thread, looking for a more defined way to place comments in restructuredtext. Personally, I also of course don't like the one-liner
.. this is a comment
. To keep comments searchable and recognizable, I propose to consider usingAs documented (http://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html): "Undefined tags are false", such as
comment
.Alternatively, one could write an extension in the style of todo, allowing syntax, such as
Doing so without such extension of course gives error messages from the builder. But with such extension, just like todo, it would be possible to extract a list of comments from a document.
参考还提供了一个漂亮的小图表,其中显示了多个行注释很简单:
以下是参考文献中的示例,已修改为显示多行注释:
The reference also gives a nice little diagram, which shows multi-line comments are easy:
Here is an example from the reference that has been modified to show multi line comments:
检查: http://docutils.sourceforge.net/docs/user/rst /quickref.html#comments
Check: http://docutils.sourceforge.net/docs/user/rst/quickref.html#comments