gpt4 book ai didi

elm - Elm 函数可以有文档字符串吗?

转载 作者:行者123 更新时间:2023-12-04 22:15:07 24 4
gpt4 key购买 nike

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

最佳答案

可以使用以下 documentation format 为模块指定文档。 :

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 查看这些文档.甚至还有 an issue与此有关。

另一方面,有 elm-oracle库,它允许您将文档提示集成到编辑器中(并且它已经集成到 the popular ones 中),甚至可以在命令行中运行它:
elm-oracle FILE query

关于elm - Elm 函数可以有文档字符串吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51701753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com