elm - Elm 函数可以有文档字符串吗?
问题描述
Python 有它们,我发现它们非常有用:
def awesome_fn(x, y):
""""
Calculates some awesome function of x and y.
""""
.
.
.
然后在 iPython REPL 中,您可以使用
In [1]: awesome_fn?
Signature: awesome_fn(x, y)
Docstring: Calculates some awesome function of x and y.
File: ...
Type: function
解决方案
可以使用以下文档格式为模块指定文档:
module Maybe exposing (Maybe(Just,Nothing), andThen, map, withDefault, oneOf)
{-| This library fills a bunch of important niches in Elm. A `Maybe` can help
you with optional arguments, error handling, and records with optional fields.
# Definition
@docs Maybe
# Common Helpers
@docs map, withDefault, oneOf
# Chaining Maybes
@docs andThen
-}
对于一个方法:
{-| Convert a list of characters into a String. Can be useful if you
want to create a string primarly by consing, perhaps for decoding
something.
fromList ['e','l','m'] == "elm"
-}
fromList : List Char -> String
fromList = ...
但目前无法从repl
. 甚至还有一个与此相关的问题。
另一方面,还有elm-oracle库,它允许您将文档提示集成到编辑器中(并且它已经集成到流行的编辑器中),甚至可以在命令行中运行它:
elm-oracle FILE query
推荐阅读
- c++ - 在为 LINUX 创建共享库时如何避免 STL 的私有/弱副本
- javascript - 使用“set”使用 Mongoose 更新现有子文档的数组元素有困难吗?
- reactjs - React Typescript 应用程序的屏幕变为空白
- javascript - npm 是否会始终安装指定范围内的最新可用版本?
- javascript - 如何从 Django 中的 html 或 js 访问环境变量
- c++ - 根据用户输入用字母填充向量,并将 Start 和 End 放在四肢上
- json - 如何在 vue js 应用程序中单击按钮下载 json 文件
- ubuntu - 为动态域(如通配符)发出 ssl
- r - 为 sf 对象的绘图设置色阶限制
- r - 为R中的每一行生成具有不同概率的随机数