Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 62 lines (49 sloc) 1.741 kB
37232e3 @rgrove Initial commit.
rgrove authored
1 #!/usr/bin/env ruby
2
3 # This script converts a YUIDoc raw.json metadata file into a vim language
4 # syntax. It requires the erubis and json gems.
5
6 require 'rubygems'
7 require 'erubis'
8 require 'json'
9
10 # Words that need to be escaped in the syntax output.
11 ESCAPE = %w{
12 contained containedin contains display fold nextgroup oneline skipempty
13 skipnl skipwhite transparent
14 }
15
16 EXCLUDE_CLASSES = []
17 EXCLUDE_CONSTANTS = []
18 EXCLUDE_FUNCTIONS = ['()', 'DEFAULT_GETTER', 'DEFAULT_SETTER']
19 EXCLUDE_VARIABLES = []
20
21 api = JSON.parse(File.read('raw.json'))
22
23 classes = []
24 constants = []
25 functions = []
26 variables = []
27 version = api['version']
28
29 api['classmap'].each do |classname, classdata|
30 # Classes
31 classname.split('.').each do |name|
32 classes << name unless name.include?('~') || EXCLUDE_CLASSES.include?(name)
33 end
34
35 # Constants/Variables/Properties
36 (classdata['properties'] || {}).each do |propname, propdata|
37 next if propdata['protected'] || propdata['private']
38 propname = $1 if propname =~ /\.([^\.]+)$/
39
40 if propdata['final']
41 constants << propname unless EXCLUDE_CONSTANTS.include?(propname)
42 else
43 variables << propname unless EXCLUDE_VARIABLES.include?(propname)
44 end
45 end
46
47 # Functions/Methods
48 (classdata['methods'] || {}).each do |methodname, methoddata|
49 next if methoddata['protected'] || methoddata['private'] || methodname =~ /\s/
50 methodname = $1 if methodname =~ /\.([^\.]+)$/
51 functions << methodname unless EXCLUDE_FUNCTIONS.include?(methodname)
52 end
53 end
54
55 [classes, constants, functions, variables].each do |keywords|
56 keywords.uniq!
57 keywords.sort!
58 keywords.map! {|w| ESCAPE.include?(w) ? "\\#{w}" : w }
59 end
60
61 puts Erubis::Eruby.new(File.read('syntax.erb')).result(binding)
Something went wrong with that request. Please try again.