Skip to content

Commit d9b21ee

Browse files
committed
Document CTags
1 parent 0f8a4d6 commit d9b21ee

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ It is built with only standard library dependencies. It additionally ships with
1515
- [CLI](#cli)
1616
- [ast](#ast)
1717
- [check](#check)
18+
- [ctags](#ctags)
1819
- [expr](#expr)
1920
- [format](#format)
2021
- [json](#json)
@@ -139,6 +140,33 @@ To change the print width that you are checking against, specify the `--print-wi
139140
stree check --print-width=100 path/to/file.rb
140141
```
141142

143+
### ctags
144+
145+
This command will output to stdout a set of tags suitable for usage with [ctags](https://github.com/universal-ctags/ctags).
146+
147+
```sh
148+
stree ctags path/to/file.rb
149+
```
150+
151+
For a file containing the following Ruby code:
152+
153+
```ruby
154+
class Foo
155+
end
156+
157+
class Bar < Foo
158+
end
159+
```
160+
161+
you will receive:
162+
163+
```
164+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
165+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
166+
Bar test.rb /^class Bar < Foo$/;" c inherits:Foo
167+
Foo test.rb /^class Foo$/;" c
168+
```
169+
142170
### expr
143171

144172
This command will output a Ruby case-match expression that would match correctly against the first expression of the input.

lib/syntax_tree/cli.rb

+3
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ def run(item)
413413
#{Color.bold("stree check [--plugins=...] [--print-width=NUMBER] [-e SCRIPT] FILE")}
414414
Check that the given files are formatted as syntax tree would format them
415415
416+
#{Color.bold("stree ctags [-e SCRIPT] FILE")}
417+
Print out a ctags-compatible index of the given files
418+
416419
#{Color.bold("stree debug [--plugins=...] [--print-width=NUMBER] [-e SCRIPT] FILE")}
417420
Check that the given files can be formatted idempotently
418421

0 commit comments

Comments
 (0)