2016-05-23 76 views
2

我想通過ctags從我的理性項目生成標籤。但它仍然沒有選擇正確的字符串。貝婁是我正在使用的參數。我錯過了什麼?成功運行後,我希望有./.tags文件將包含所有的任務名稱。我從Homebrew使用ctags 5.8。ctags爲理想項目

順便說一句,我開始在這裏 - http://blog.iany.me/2015/02/ctags-for-ansible/

命令/usr/local/Cellar/ctags/5.8_1/bin/ctags -f .tags --recurse .

./.ctags

--langdef=ansible 
--langmap=ansible:.yml.yaml 
--regex-ansible=/^[ \t]*-[ \t]*name:[ \t]*([\w\s]+)\n/\1/i 
--languages=+ansible 

例任務文件

--- 
- name: install docker-py 
    pip: name=docker-py version=1.7.2 
    become: yes 

- name: Install tmux 
    yum: 
    name: tmux 
    state: present 
    update_cache: yes 
    become: yes 

我不堅持CTAGS。我的目標是爲Atom編輯器提供符號,以便我可以快速跳過Ansible項目。

回答

2

恢復到鏈接頁面上的示例,使其工作。我想我做了不必要的更改,然後我從Homebrew安裝ctags

0

ctags命令有許多不同的實現。

使用與GNU Emacs的交付ctags,我有以下成功:

ctags --language=none --regex='^[ \t]*-[ \t]*name:[ \t]*\(.*?\)[ \t]*$' *.yml roles/*/tasks/*.yml roles/*/handlers/*.yml 

這也適用於etags

0

universal-ctags內置(但不完整)ansible playbook支持。

[[email protected]]~/var/ctags% cat foo.yml 
--- 
- name: install docker-py 
    pip: name=docker-py version=1.7.2 
    become: yes 

- name: Install tmux 
    yum: 
    name: tmux 
    state: present 
    update_cache: yes 
    become: yes 
[[email protected]]~/var/ctags% ./ctags --version     
Universal Ctags 0.0.0(5567535e), Copyright (C) 2015 Universal Ctags Team 
Universal Ctags is derived from Exuberant Ctags. 
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert 
    Compiled: Jul 26 2017, 04:24:17 
    URL: https://ctags.io/ 
    Optional compiled features: +wildcards, +regex, +multibyte, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +aspell 
[[email protected]]~/var/ctags% ./ctags --fields=+Kl -o - foo.yml 
Install tmux foo.yml /^- name: Install tmux$/;" play language:AnsiblePlaybook 
install docker-py foo.yml /^- name: install docker-py$/;" play language:AnsiblePlaybook