请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

naiquevin/sphinx-doc.el: Generate Sphinx friendly docstrings for Python function ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

naiquevin/sphinx-doc.el

开源软件地址:

https://github.com/naiquevin/sphinx-doc.el

开源编程语言:

Emacs Lisp 98.4%

开源软件介绍:

sphinx-doc.el

What is it?

sphinx-doc is an emacs minor mode for inserting docstring skeleton for Python functions and methods. The structure of the docstring is as per the requirement of the Sphinx documentation generator.

Installation

This package can be installed from MELPA. To do so, run M-x package-list-packages, then search for "sphinx-doc". Mark it with i and finally press x to install.

To install manually, download and copy the sphinx-doc.el file somewhere in the load path.

Configuration

Add the following line to your .emacs (or the equivalent config file)

    (add-hook 'python-mode-hook (lambda ()
                                  (require 'sphinx-doc)
                                  (sphinx-doc-mode t)))

This will enable the sphinx-doc-mode and bind the interactive function sphinx-doc to C-c M-d.

To include type parameters in your docstring, set sphinx-doc-include-types to t.

Usage

Inside a Python file, move the cursor to some function/method definition and hit C-c M-d (see gif demo below).

Demo

Sphinx-doc

Known Issues

  • The parser is whitespace-sensitive. If there are trailing spaces at the end of the function definition line, then the parser will fail. Also, if you do not have at before the type name in your type-hints, then the parser will fail.

  • When calling the function interactively, if the cursor is not on the head of a function definition (ie. the keyword def, function name or the parenthesized list of the formal parameters) it either shows a "search failed" message in the minibuffer or inserts documentation for a valid function definition closer to the current line! Although both behaviours are quite harmless, it's annoying and definitely needs to be fixed. Patches welcome!

See also

  • The autodoc extension needs to be enabled for the sphinx instance in order to generate documentation from the docstrings.

  • If anyone's interested, there is a similar functionality I wrote to generate docstrings for Javscript functions based on the style of Natural Docs. It's not packaged as a mode but can be installed manually. Natural Docs for Javascript in Emacs

License

MIT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

上一篇:
kiwanami/emacs-skype: Skype UI for emacs users发布时间:2022-05-08
下一篇:
Emacs-D-Mode-Maintainers/Emacs-D-Mode: An Emacs mode for D code.发布时间:2022-05-08
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap