python sphinx线长自动修正

发布于 2024-11-09 04:44:48 字数 356 浏览 7 评论 0原文

通常,与 sphinx 相关的最佳实践要求您必须将行长度限制为少于 80 个字符。

所以我想要一种方法来自动将行长度限制为少于 80 个字符(没有连字符),并且当发生更正时,它必须放置正确的缩进(如果可能)。 我见过的唯一一个似乎有点合适的功能是 Textwrap http://docs.python .org/library/textwrap.html 有人有这方面的经验吗?也许有更好的主意?该功能已经捆绑在 sphinx 中,但我没有找到它?我错过了 stackoverflow 中的某个主题?

欢迎任何意见。

Usually, best practices related to sphinx says that you must limit the line length to less than 80 characters.

So I want a way to automatically limit my line length to less than 80 characters (with no hyphens) and when the correction happens, it has to put the correct indent (if possible).
The only function I've seen who seems to fit a bit is the Textwrap http://docs.python.org/library/textwrap.html
Someone has some experiences with this? a better idea maybe? The function is already bundle in sphinx but I don't find it ? I miss a topic in stackoverflow?

Any input is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半透明的墙 2024-11-16 04:44:48

您需要的是血统编辑器。

例如,在 vim 中,这是通过执行以下操作来处理的:

:set textwidth=80

然后您所要做的就是开始输入,vim 将继续下一行。

标记文本并根据“textwidth”变量的设置执行 gq 重新格式化所选内容。

前任。

In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri.

在设置 tw=30 后的 vim 中,选择文本并执行 gq

In those days spirits were
brave, the stakes were high,
men were real men, women were
real women and small furry
creatures from Alpha Centauri
were real small furry
creatures from Alpha Centauri.

A descent editor is what you need.

In vim for example this is handled by doing:

:set textwidth=80

Then all you have to do is start typing and vim will continue on the nextline.

Marking text and doing a gq reformats the selection according to the setting of the "textwidth" variable.

Ex.

In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri.

In vim after setting tw=30, selecting text and doing a gq:

In those days spirits were
brave, the stakes were high,
men were real men, women were
real women and small furry
creatures from Alpha Centauri
were real small furry
creatures from Alpha Centauri.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文