【转载】devhelp的使用小结 --zealoussnow

来源:互联网 发布:注册了com的域名能卖吗 编辑:程序博客网 时间:2024/05/22 16:41

这篇文章转载于  http://blog.chinaunix.net/uid-28422527-id-4309534.html

作者 zealoussnow   zealoussnow的ChinaUnix博客


网上比较少中文的devhelp的信息,所以想转过来。

如有侵权请立即与我们联系,我们将及时处理



devhelp是一个很方便的图形化文档查看器,自从发现了devhelp,感觉查阅帮助文档舒服多了。在linux写程序让我颇感遗憾的是manpage没有c++的,但在devhelp中也没有好一点的c++文档,所以就萌生了将cppreference上的离线文档放到devhelp中的做法。说干就干,尝试以下呗!

    查阅了下devhelp的readme,发现devhelp搜寻文档的目录有:        
        (1). $XDG_DATA_HOME/devhelp/books
        (2). $XDG_DATA_HOME/gtk-doc/html
        (3). $XDG_DATA_DIRS/devhelp/books
        (4). $XDG_DATA_DIRS/gtk-doc/html
    我就直接自己的家目录作为devhelp的文档搜索路径。export XDG_DATA_HOME=$HOME/.local/share,然后新建目录devhelp/books,在books下面就是文档的位置。由于我经常查阅的是c++和c的一些文档,这里我举的例子是cppreference的一个离线文档
    将下载的离线文档解压到$XDG_DATA_HOME/devhelp/books下面,目录名改为cpp-reference。
    首先呢,我们需要一个以.devhelp结尾的文件,这个实际上就是一个xml文件,用于展示文档结构。我呢也不自己写了,以前devhelp里面我个libxml2的文档,就用它啦。在cpp-reference目录下新建一个cpp-reference.devhelp, 观察下cppreference的结构,c部分和c++部分在en目录下面。所以呢,这个devhelp文件可以这么写,我直接就展示修改后的文件了,很容易看懂的。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <book xmlns="http://www.devhelp.net/book" title="C++ Reference Manual" link="en/index.html" author="zealoussnow" name="cppreference">
  3.     <chapters>
  4.         <sub name="C" link="en/c.html">
  5.             <sub name="algorithm" link="en/c/algorithm.html"/>
  6.             <sub name="atomic" link="en/c/atomic.html"/>
  7.             <sub name="chrono" link="en/c/chrono.html"/>
  8.             <sub name="error" link="en/c/error.html"/>
  9.             <sub name="header" link="en/c/header.html"/>
  10.             <sub name="keyword" link="en/c/keyword.html"/>
  11.             <sub name="language" link="en/c/language.html"/>
  12.             <sub name="links" link="en/c/links.html"/>
  13.             <sub name="locale" link="en/c/locale.html"/>
  14.             <sub name="memory" link="en/c/memory.html"/>
  15.             <sub name="preprocessor" link="en/c/preprocessor.html"/>
  16.             <sub name="program" link="en/c/program.html"/>
  17.             <sub name="string" link="en/c/string.html"/>
  18.             <sub name="thread" link="en/c/thread.html"/>
  19.             <sub name="types" link="en/c/types.html"/>
  20.         </sub>
  21.         <sub name="C++" link="en/cpp.html">
  22.             <sub name="algorithm" link="en/cpp/algorithm.html"/>
  23.             <sub name="chrono" link="en/cpp/chrono.html"/>
  24.             <sub name="comment" link="en/cpp/comment.html"/>
  25.             <sub name="concept" link="en/cpp/concept.html"/>
  26.             <sub name="containter" link="en/cpp/container.html"/>
  27.             <sub name="error" link="en/cpp/error.html"/>
  28.             <sub name="header" link="en/cpp/header.html"/>
  29.             <sub name="io" link="en/cpp/io.html"/>
  30.             <sub name="iterator" link="en/cpp/iterator.html"/>
  31.             <sub name="keyword" link="en/cpp/keyword.html"/>
  32.             <sub name="language" link="en/cpp/language.html"/>
  33.             <sub name="links" link="en/cpp/links.html"/>
  34.             <sub name="locale" link="en/cpp/locale.html"/>
  35.             <sub name="memory" link="en/cpp/memory.html"/>
  36.             <sub name="numberic" link="en/cpp/numberic.html"/>
  37.             <sub name="preprocessor" link="en/cpp/preprocessor.html"/>
  38.             <sub name="regex" link="en/cpp/regex.html"/>
  39.             <sub name="string" link="en/cpp/string.html"/>
  40.             <sub name="thread" link="en/cpp/thread.html"/>
  41.             <sub name="types" link="en/cpp/types.html"/>
  42.             <sub name="utility" link="en/cpp/utility.html"/>
  43.         </sub>
  44.     </chapters>
  45.     <functions>
  46.         <function name="swap()" link="en/cpp/io/basic_filebuf/swap.html"/>
  47.     </functions>
  48. </book>
    是不是很简单,其实就包含三部分:sub name为C和C++的节点,还有一个functions节点。functions那个swap()我只是为了举个例子,实际上还能加很多的,这是为了在search部分查询方便。
    写完之后再次打开devhelp,新增的文档就出现了,查询起来十分方便,是不是很amazing啊。
    
原创粉丝点击