标准库标签
我将标签文件用于 代码完成以及参数、重载、文件(声明的位置)等的快速内联视图。在哪里可以找到 C99、C++03 和 C++0x 标准库的免费可用标签? (C89 总比没有好,但我宁愿有 C99。)
我更喜欢没有瑕疵的标签;例如,实现使用参数的保留名称,因此我宁愿看到“std::min(a, b)”,而不是“std::min(_M_a, _M_b)”。这个问题和其他问题排除了从实际实现中生成的可能性。尽管我认为一些后处理可能会清理这些问题(尤其是标识符问题),但从头开始编写似乎会更容易。
I use tag files for code completion and for a quick, inline view of parameters, overloads, files (where declared), etc. Where can I find freely available tags for the C99, C++03, and C++0x standard libraries? (C89 would be better than nothing, but I'd rather have C99.)
I prefer tags without cruft; e.g. implementations use reserved names for parameters, so instead of "std::min(_M_a, _M_b)", I'd rather see "std::min(a, b)". This and other issues rule out generating from actual implementations. Though I suppose some postprocessing might clean those up (especially the identifier issue), it almost seems like it would be easier to write from scratch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
通常,从
libc
中提取标签很困难,因为函数声明很可能在标头中作为复杂的宏实现。人们可以使用 nm 来查找 a 库导出的符号列表,但这并不能解决参数列表的问题。我认为最好的解决方案是解析文档:
以易于解析的格式导出的所有函数和宏的列表:
这是由
libc
org/s/libc/manual/html_node/Function-Index.html#Function-Index" rel="nofollow">http://www.gnu.org/s/libc/manual/html_node/Function-Index.html# Function-Index每个函数都链接到一个页面,该页面列出了该函数的参数,也采用可预测的格式:
http://www.gnu.org/s/libc/manual/html_node/Block-Input_002fOutput.html#index-fread-1010
使用
BeautifulSoup
Python 模块解析页面非常容易。Generally it is difficult to extract tags from
libc
because function declarations are likely to be implemented in the headers as complex macros. One can usenm
to find a list of symbols exported by the a library, but that doesn't address the parameter list.I think the best solution here is to parse the documentation:
Here is a list of all functions and macros exported by
libc
in an easily parsed format:http://www.gnu.org/s/libc/manual/html_node/Function-Index.html#Function-Index
Each function links to a page that lists the parameters for that function, also in a predictable format:
http://www.gnu.org/s/libc/manual/html_node/Block-Input_002fOutput.html#index-fread-1010
Parsing the pages are pretty easy using
BeautifulSoup
Python module.对于这些确切的要求,您可能必须自己创建:(
For those exact requirements you will probably have to create those yourself :(
使用标题目录上的 ctags 为自己生成一个标签库,就像您在问题中链接的博客文章中所写的那样
generate yourself a tag library using ctags on headers dir, like written in the post blog you link in your question
这不是一个完整的答案。有人发布了一个 perl 脚本来从 SGI 的 STL 文档中提取标签。它不包括函数参数名称。由于它适用于文档,因此没有任何麻烦。希望这会有所帮助。
This is not a complete answer. Someone published a perl script to extract tags from SGI's STL documentation. It does not include function parameter names. Since it works on the documentation there is no cruft. Hope this helps a bit.
如果完成标准库是主要问题,clang vim 插件根本不使用标签就可以很好地做到这一点。然而,补全中仍然存在一些参数“cruft”,因为它使用了标头使用的符号。
你主要只需将一个文件放入 ~/.vim/plugin 中,安装 clang,它就可以工作了。比全能路线简单得多。到目前为止,我在有限使用它时遇到的唯一问题是,有时完成速度很慢。
If getting completion for standard libraries is the main issue, the clang vim plugin does this quite well without using tags at all. There is however, still some parameter "cruft" in the completions, as it uses the symbols used by the header.
You mainly just drop one file in ~/.vim/plugin, install clang, and it works. Much simpler than the omnicomplete route. The only issue I've had so far in my limited use of it is that it is sometimes slow coming up with the completions.