有没有可能为Haskell核心库(或者更多)获得离线文档呢?
有时我会带着我的笔记本电脑去没有WiFi的咖啡店,如果有像Hoogle这样的离线工具就太好了。
Hoogle可以离线使用,可从Cabal安装:http://hackage.haskell.org/package/hoogle
使用说明在http://www.haskell.org/haskellwiki/Hoogle#Command_Line_Search_Flags上。
用法:
$ hoogle --help
Hoogle v4.2.8, (C) Neil Mitchell 2004-2011
http://haskell.org/hoogle
hoogle [COMMAND] ... [OPTIONS]
Commands:
[search] Perform a search
data Generate Hoogle databases
server Start a Hoogle server
combine Combine multiple databases into one
convert Convert an input file to a database
test Run tests
dump Dump sections of a database to stdout
rank Generate ranking information
log Analyse log files
Common flags:
-? --help Display help message
-V --version Print version information
-v --verbose Loud verbosity
-q --quiet Quiet verbosity
使用hoogle data
创建默认数据库(更多信息请参见http://neilmitchell.blogspot.com/2008/08/hoogle-database-generation.html)。
编辑:在本地安装Hoogle后的使用会话:
$ hoogle
No query entered
Try --help for command line options
$ hoogle data
(downloads databases...takes a few minutes)
hoogle data all
,但由于花费的时间太长(它似乎要搜索Hackage上的每个包),我取消了它。它仍然不允许像hoogle map
这样的查询,但允许hoogle map +base
(即将搜索限制为base
包)。希望它对你有用!$cd .cabal/share/hoogle-4.2.8/databases
$hoogle combine base.hoo
$hoogle foldl\'
Data.List foldl' :: (a -> b -> a) -> a -> [b] -> a
Data.Foldable foldl' :: Foldable t => (a -> b -> a) -> a -> t b -> a
HTML文档可以从Haskell网站下载为.tar.bz2
文件:
https://downloads.haskell.org/~ghc/latest/docs/
我刚刚下载了https://www.haskell.org/ghc/docs/7.6.3/libraries.html.tar.bz2,正是我一直期待的。
还有其他选项,例如Dash和Zeal,另请参见reddit帖子。
hoogle server --local
实现目的。 - user24601haskell-platform-doc
这样的文档包。 - li.davidm编辑您的~/.cabal/config文件。查找一行(可能被注释掉)写着documentation: False
。将该行更改为documentation: True
并取消注释。现在使用cabal install
安装项目时也会构建和保存文档。
在同一配置文件中继续寻找,您会找到像doc-index-file、docdir、datadir、prefix等选项,可以让您配置文档存储的位置。
cabal-install
构建项目,则可以在~/.cabal/config
中设置documentation: True
,然后重新安装依赖项以在本地生成haddocks。stack haddock
命令来构建您的依赖项和生成的Haddocks项目。如果您正在使用基于Debian的发行版及其软件包,则会在以下位置找到所有已安装的Haskell软件包的组合文档(如果您还安装了libghc-foo-doc
软件包):
file:///usr/share/doc/ghc-doc/html/libraries/index.html
libghc-foo-doc
包含了 hoogle 所需的必要文件,因此如果你使用 apt-get install hoogle
命令安装了它,那么你就可以立即使用 hoogle
来搜索通过这种方式安装的所有库。
~/.cabal/config
文件中添加documentation: True
,然后使用cabal install world --reinstall
命令重新安装这些包。 - hammarhoogle data --local
花费了我3分钟(其中大部分时间用于下载)。然后我可以运行hoogle foldl
来查找foldl函数,或者运行hoogle server --local
并访问http://localhost/
,这是一个完整的服务器,并包含HTML文档的链接。 - Neil Mitchellhoogle data all
和hoogle data --local
下载了很多东西,但仍然无法让我在包中找到函数(例如parseFileWithMode
)。这个功能应该可以用吗? - nh2