Prune unused grammars

script/prune-grammars will remove any grammars that aren't needed from
grammars.yml.
This commit is contained in:
Adam Roben
2014-11-13 13:16:24 -05:00
parent 046fb18980
commit 2870f6d038
2 changed files with 57 additions and 240 deletions

View File

@@ -5,60 +5,20 @@ http://svn.edgewall.org/repos/genshi/contrib/textmate/Genshi.tmbundle/Syntaxes/M
- text.xml.genshi
http://svn.textmate.org/trunk/Review/Bundles/BlitzMax.tmbundle:
- source.blitzmax
http://svn.textmate.org/trunk/Review/Bundles/Cron.tmbundle:
- text.crontab
http://svn.textmate.org/trunk/Review/Bundles/Cython.tmbundle:
- source.cython
http://svn.textmate.org/trunk/Review/Bundles/F%20Sharp.tmbundle:
- source.fsharp
http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle:
- source.forth
http://svn.textmate.org/trunk/Review/Bundles/Google%20Code.tmbundle:
- text.html.googlecodewiki
http://svn.textmate.org/trunk/Review/Bundles/JUNOScript.tmbundle:
- source.slax
http://svn.textmate.org/trunk/Review/Bundles/Java%20Velocity.tmbundle:
- text.html.velocity
- text.velocity
http://svn.textmate.org/trunk/Review/Bundles/K.tmbundle:
- source.k
http://svn.textmate.org/trunk/Review/Bundles/Limbo.tmbundle:
- source.limbo
http://svn.textmate.org/trunk/Review/Bundles/Maude.tmbundle:
- source.maude
http://svn.textmate.org/trunk/Review/Bundles/Mx.tmbundle:
- source.mx
http://svn.textmate.org/trunk/Review/Bundles/PDB.tmbundle:
- source.pdb
http://svn.textmate.org/trunk/Review/Bundles/PHP%20Cake.tmbundle:
- text.html.php.cake
http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle:
- source.parrot.pir
http://svn.textmate.org/trunk/Review/Bundles/RelaxNG.tmbundle:
- source.rnc
http://svn.textmate.org/trunk/Review/Bundles/Ruby%20Sass.tmbundle:
- source.sass
http://svn.textmate.org/trunk/Review/Bundles/Ruby%20Shoulda.tmbundle:
- source.ruby.rails.shoulda
http://svn.textmate.org/trunk/Review/Bundles/SecondLife%20LSL.tmbundle:
- source.lsl
http://svn.textmate.org/trunk/Review/Bundles/TYPO3.tmbundle:
- source.typoscript
- text.xml.t3datastructure
http://svn.textmate.org/trunk/Review/Bundles/Taskmate.tmbundle:
- text.taskmate
http://svn.textmate.org/trunk/Review/Bundles/Tasks.tmbundle:
- text.tasks
http://svn.textmate.org/trunk/Review/Bundles/Treetop.tmbundle:
- source.treetop
http://svn.textmate.org/trunk/Review/Bundles/VHDL.tmbundle:
- source.vhdl
http://svn.textmate.org/trunk/Review/Bundles/Wikidot.tmbundle:
- text.html.wikidot
http://svn.textmate.org/trunk/Review/Bundles/XQuery.tmbundle:
- source.xquery
http://svn.textmate.org/trunk/Review/Bundles/iPhone.tmbundle:
- source.objc.iPhone
https://bitbucket.org/Clams/sublimesystemverilog/get/default.tar.gz:
- source.systemverilog
- source.ucfconstraints
@@ -80,8 +40,6 @@ https://github.com/JohnNilsson/awk-sublime/raw/master/AWK.tmLanguage:
- source.awk
https://github.com/Oldes/Sublime-REBOL:
- source.rebol
https://github.com/PogiNate/Sublime-Inform/raw/master/Inform7/inform7.tmLanguage:
- source.Inform7
https://github.com/Red-Nova-Technologies/autoitv3-tmbundle:
- source.autoit.3
https://github.com/SalGnt/Sublime-VimL:
@@ -108,8 +66,6 @@ https://github.com/aroben/ada.tmbundle/raw/c45eed4d5f98fe3bcbbffbb9e436601ab5bbd
https://github.com/aroben/ruby.tmbundle@4636a3023153c3034eb6ffc613899ba9cf33b41f:
- source.ruby
- text.html.erb
https://github.com/asbjornenge/Docker.tmbundle:
- source.dockerfile
https://github.com/atom/language-coffee-script:
- source.coffee
- source.litcoffee
@@ -173,9 +129,6 @@ https://github.com/guillermooo/dart-sublime-bundle/raw/master/Dart.tmLanguage:
- source.dart
https://github.com/harrism/sublimetext-cuda-cpp/raw/master/cuda-c%2B%2B.tmLanguage:
- source.cuda-c++
https://github.com/infininight/turtle.tmbundle:
- source.sparql
- source.turtle
https://github.com/jeancharles-roger/ceylon-sublimetext/raw/master/Ceylon.tmLanguage:
- source.ceylon
https://github.com/jfairbank/Sublime-Text-2-OpenEdge-ABL:
@@ -188,11 +141,6 @@ https://github.com/joshaven/RDoc.tmbundle:
- text.rdoc
https://github.com/jpcamara/Textmate-Gosu-Bundle/raw/master/Gosu.tmbundle/Syntaxes/Gosu.tmLanguage:
- source.gosu.2
https://github.com/kraih/mojo.tmbundle:
- source.perl.mojolicious
- text.html.mojolicious
https://github.com/kswedberg/jquery-tmbundle:
- source.js.jquery
https://github.com/kuroir/SCSS.tmbundle:
- source.scss
https://github.com/laughedelic/sublime-idris/raw/master/Idris.tmLanguage:
@@ -224,14 +172,10 @@ https://github.com/mkolosick/Sublime-Coq/raw/master/Coq.tmLanguage:
- source.coq
https://github.com/mokus0/Agda.tmbundle:
- source.agda
https://github.com/mxcl/Roole.tmBundle:
- source.roole
https://github.com/nanoant/Julia.tmbundle:
- source.julia
https://github.com/nanoant/assembly.tmbundle/raw/master/Syntaxes/objdump%20C%2B%2B.tmLanguage:
- objdump.x86asm
https://github.com/nasser/arduino.tmbundle:
- source.c++.arduino
https://github.com/nilium/ooc.tmbundle:
- source.ooc
https://github.com/paulmillr/LiveScript.tmbundle:
@@ -242,8 +186,6 @@ https://github.com/puppet-textmate-bundle/puppet-textmate-bundle:
- source.puppet
https://github.com/pvl/abap.tmbundle:
- source.abap
https://github.com/rspec/rspec-tmbundle:
- source.ruby.rspec
https://github.com/scalate/Scalate.tmbundle:
- source.scaml
- text.html.ssp
@@ -255,12 +197,8 @@ https://github.com/simongregory/actionscript3-tmbundle:
- source.actionscript.3
- text.html.asdoc
- text.xml.flex-config
https://github.com/simongregory/flex-tmbundle:
- text.xml.mxml
https://github.com/skozlovf/Sublime-QML:
- source.qml
https://github.com/skurfer/LDIF.tmbundle:
- text.ldif
https://github.com/slash-lang/Slash.tmbundle:
- text.html.slash
https://github.com/slavapestov/factor/raw/master/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage:
@@ -279,17 +217,6 @@ https://github.com/swannodette/textmate-clojure:
- source.clojure
https://github.com/technosophos/Vala-TMBundle:
- source.vala
https://github.com/textmate/Mustache.tmbundle:
- text.html.mustache
https://github.com/textmate/actionscript.tmbundle:
- source.actionscript.2
https://github.com/textmate/active4d.tmbundle:
- source.active4d
- source.active4d.library
- text.active4d-ini
- text.html.strict.active4d
https://github.com/textmate/ant.tmbundle:
- text.xml.ant
https://github.com/textmate/antlr.tmbundle:
- source.antlr
https://github.com/textmate/apache.tmbundle:
@@ -300,33 +227,12 @@ https://github.com/textmate/applescript.tmbundle:
https://github.com/textmate/asp.tmbundle:
- source.asp
- text.html.asp
https://github.com/textmate/asp.vb.net.tmbundle:
- source.asp.vb.net
- text.html.asp.net
https://github.com/textmate/bison.tmbundle:
- source.bison
https://github.com/textmate/blogging.tmbundle:
- text.blog
- text.blog.html
- text.blog.markdown
- text.blog.textile
https://github.com/textmate/bulletin-board.tmbundle:
- text.bbcode
https://github.com/textmate/bundle-development.tmbundle:
- source.plist.textmate.grammar
- source.plist.textmate.settings
- text.tm-scope
- text.tm-snippet
https://github.com/textmate/c.tmbundle:
- source.c
- source.c++
https://github.com/textmate/capnproto.tmbundle:
- source.capnp
https://github.com/textmate/cmake.tmbundle:
- source.cache.cmake
- source.cmake
https://github.com/textmate/context-free.tmbundle:
- source.context-free
https://github.com/textmate/cpp-qt.tmbundle:
- source.c++.qt
- source.qmake
@@ -336,10 +242,6 @@ https://github.com/textmate/d.tmbundle:
- source.d
https://github.com/textmate/diff.tmbundle:
- source.diff
https://github.com/textmate/dokuwiki.tmbundle:
- text.html.dokuwiki
https://github.com/textmate/doxygen.tmbundle:
- text.html.doxygen
https://github.com/textmate/dylan.tmbundle:
- source.dylan
- source.lid
@@ -349,48 +251,22 @@ https://github.com/textmate/eiffel.tmbundle:
https://github.com/textmate/erlang.tmbundle:
- source.erlang
- text.html.erlang.yaws
https://github.com/textmate/f-script.tmbundle:
- source.fscript
https://github.com/textmate/fortran.tmbundle:
- source.fortran
- source.fortran.modern
https://github.com/textmate/fxscript.tmbundle:
- source.fxscript
https://github.com/textmate/gettext.tmbundle:
- source.po
https://github.com/textmate/git.tmbundle:
- source.git-config
- text.git-commit
- text.git-rebase
https://github.com/textmate/graphviz.tmbundle:
- source.dot
https://github.com/textmate/greasemonkey.tmbundle:
- source.js.greasemonkey
https://github.com/textmate/gri.tmbundle:
- source.gri
https://github.com/textmate/groovy-grails.tmbundle:
- text.html.grails
https://github.com/textmate/groovy.tmbundle:
- source.groovy
https://github.com/textmate/gtd2.tmbundle:
- text.html.markdown.wiki.gtd
https://github.com/textmate/gtdalt.tmbundle:
- text.gtdalt
https://github.com/textmate/haskell.tmbundle:
- source.haskell
- text.tex.latex.haskell
https://github.com/textmate/html.tmbundle:
- text.html.basic
https://github.com/textmate/hyperlink-helper.tmbundle:
- text.hyperlink
https://github.com/textmate/icalendar.tmbundle:
- source.icalendar
https://github.com/textmate/inform.tmbundle:
- source.inform
https://github.com/textmate/ini.tmbundle:
- source.ini
https://github.com/textmate/installer.tmbundle:
- text.xml.apple-dist
https://github.com/textmate/io.tmbundle:
- source.io
https://github.com/textmate/java.tmbundle:
@@ -398,19 +274,8 @@ https://github.com/textmate/java.tmbundle:
- source.java-properties
- text.html.jsp
- text.junit-test-report
https://github.com/textmate/javadoc.tmbundle:
- text.html.javadoc
https://github.com/textmate/javascript-flash.tmbundle:
- source.js.jsfl
https://github.com/textmate/javascript-mootools.tmbundle:
- source.js.mootools
https://github.com/textmate/javascript-objective-j.tmbundle:
- source.js.objj
https://github.com/textmate/javascript-prototype-and-script.aculo.us.tmbundle:
- source.js.prototype
- source.js.prototype.bracketed
https://github.com/textmate/javascript-yui.tmbundle:
- source.js.yui
https://github.com/textmate/json.tmbundle:
- source.json
https://github.com/textmate/latex.tmbundle:
@@ -422,55 +287,23 @@ https://github.com/textmate/latex.tmbundle:
- text.tex.latex.memoir
https://github.com/textmate/less.tmbundle:
- source.css.less
https://github.com/textmate/lex-flex.tmbundle:
- source.lex
https://github.com/textmate/lighttpd.tmbundle:
- source.lighttpd-config
https://github.com/textmate/lilypond.tmbundle:
- source.lilypond
https://github.com/textmate/lisp.tmbundle:
- source.lisp
https://github.com/textmate/logo.tmbundle:
- source.logo
https://github.com/textmate/logtalk.tmbundle:
- source.logtalk
https://github.com/textmate/lua.tmbundle:
- source.lua
https://github.com/textmate/macports.tmbundle:
- source.tcl.macports
https://github.com/textmate/mail.tmbundle:
- text.mail
- text.mail.markdown
https://github.com/textmate/make.tmbundle:
- source.makefile
https://github.com/textmate/man-pages.tmbundle:
- text.man
https://github.com/textmate/markdown.tmbundle:
- text.html.markdown
https://github.com/textmate/matlab.tmbundle:
- source.matlab
- source.octave
https://github.com/textmate/maven.tmbundle:
- text.xml.pom
https://github.com/textmate/mediawiki.tmbundle:
- text.html.mediawiki
https://github.com/textmate/mel.tmbundle:
- source.mel
https://github.com/textmate/mercurial.tmbundle:
- text.hg-commit
https://github.com/textmate/mips.tmbundle:
- source.mips
https://github.com/textmate/modula.tmbundle:
- source.modula-3
https://github.com/textmate/moinmoin.tmbundle:
- text.moinmoin
https://github.com/textmate/movable-type.tmbundle:
- text.html.mt
- text.html.mt.pure
https://github.com/textmate/nemerle.tmbundle:
- source.nemerle
https://github.com/textmate/ninja.tmbundle:
- source.ninja
https://github.com/textmate/objective-c.tmbundle:
- source.objc
- source.objc++
@@ -480,119 +313,46 @@ https://github.com/textmate/ocaml.tmbundle:
- source.ocaml
- source.ocamllex
- source.ocamlyacc
https://github.com/textmate/opengl.tmbundle:
- source.open-gl
https://github.com/textmate/pascal.tmbundle:
- source.pascal
https://github.com/textmate/perforce.tmbundle:
- source.perforce
https://github.com/textmate/perl-html-template.tmbundle:
- text.html.html-template
https://github.com/textmate/perl-mason.tmbundle:
- text.html.mason
https://github.com/textmate/perl-template-toolkit.tmbundle:
- text.html.tt
https://github.com/textmate/perl.tmbundle:
- source.perl
https://github.com/textmate/php-smarty.tmbundle:
- source.smarty
https://github.com/textmate/php.tmbundle:
- text.html.php
https://github.com/textmate/pmwiki.tmbundle:
- text.pmwiki
https://github.com/textmate/postscript.tmbundle:
- source.postscript
https://github.com/textmate/processing.tmbundle:
- source.processing
https://github.com/textmate/prolog.tmbundle:
- source.prolog
https://github.com/textmate/property-list.tmbundle:
- source.plist
- text.xml.plist
https://github.com/textmate/python-django.tmbundle:
- source.python.django
- text.html.django
https://github.com/textmate/quake.tmbundle:
- source.quake-config
https://github.com/textmate/r-console-r.app.tmbundle:
- source.rapp-console
https://github.com/textmate/r-console-rdaemon.tmbundle:
- source.rd.console
- source.rd.console.plain
- text.tex.latex.rdaemon
https://github.com/textmate/r.tmbundle:
- source.r
- text.tex.latex.rd
https://github.com/textmate/ragel.tmbundle:
- source.c.ragel
https://github.com/textmate/remind.tmbundle:
- source.remind
https://github.com/textmate/restructuredtext.tmbundle:
- text.restructuredtext
https://github.com/textmate/rez.tmbundle:
- source.rez
https://github.com/textmate/ruby-haml.tmbundle:
- text.haml
https://github.com/textmate/ruby-on-rails-tmbundle:
- source.js.erb.rails
- source.ruby.rails
- source.ruby.rails.rjs
- source.sql.ruby
- text.html.erb.rails
https://github.com/textmate/s5.tmbundle:
- source.s5
https://github.com/textmate/scheme.tmbundle:
- source.scheme
https://github.com/textmate/scilab.tmbundle:
- source.scilab
https://github.com/textmate/setext.tmbundle:
- text.setext
https://github.com/textmate/slate.tmbundle:
- source.slate
https://github.com/textmate/sql.tmbundle:
- source.sql
https://github.com/textmate/ssh-config.tmbundle:
- source.ssh-config
https://github.com/textmate/standard-ml.tmbundle:
- source.cm
- source.ml
https://github.com/textmate/subversion.tmbundle:
- text.svn-commit
https://github.com/textmate/sweave.tmbundle:
- text.tex.latex.sweave
https://github.com/textmate/swift.tmbundle:
- source.swift
https://github.com/textmate/swig.tmbundle:
- source.swig
https://github.com/textmate/tabular.tmbundle:
- text.tabular.csv
- text.tabular.tsv
https://github.com/textmate/tcl.tmbundle:
- source.tcl
- text.html.tcl
https://github.com/textmate/text.tmbundle:
- text.plain
https://github.com/textmate/textile.tmbundle:
- text.html.textile
https://github.com/textmate/textmate.tmbundle:
- source.regexp.oniguruma
- source.tm-properties
https://github.com/textmate/thrift.tmbundle:
- source.thrift
https://github.com/textmate/todo.tmbundle:
- text.todo
https://github.com/textmate/toml.tmbundle:
- source.toml
https://github.com/textmate/twiki.tmbundle:
- text.html.twiki
https://github.com/textmate/txt2tags.tmbundle:
- text.txt2tags
https://github.com/textmate/unicode.tmbundle:
- unicode.check.combiningMarks
- unicode.check.noASCII
- unicode.check.noLatin
https://github.com/textmate/vectorscript.tmbundle:
- source.pascal.vectorscript
https://github.com/textmate/verilog.tmbundle:
- source.verilog
https://github.com/textmate/xml.tmbundle:

57
script/prune-grammars Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env ruby
require "json"
require "linguist"
require "set"
require "yaml"
def find_includes(json)
case json
when Hash
result = []
if inc = json["include"]
result << inc unless inc.start_with?("#", "$")
end
result + json.values.flat_map { |v| find_includes(v) }
when Array
json.flat_map { |v| find_includes(v) }
else
[]
end
end
def transitive_includes(scope, includes)
scopes = Set.new
queue = includes[scope] || []
while s = queue.shift
next if scopes.include?(s)
scopes << s
queue += includes[s] || []
end
scopes
end
includes = {}
Dir["grammars/*.json"].each do |path|
scope = File.basename(path).sub(/\.json/, '')
json = JSON.load(File.read(path))
incs = find_includes(json)
next if incs.empty?
includes[scope] ||= []
includes[scope] += incs
end
yaml = YAML.load(File.read("grammars.yml"))
language_scopes = Linguist::Language.all.map(&:tm_scope).to_set
# The set of used scopes is the scopes for each language, plus all the scopes
# they include, transitively.
used_scopes = language_scopes + language_scopes.flat_map { |s| transitive_includes(s, includes) }.to_set
unused = yaml.reject { |repo, scopes| scopes.any? { |scope| used_scopes.include?(scope) } }
puts "Unused grammar repos"
puts unused.map { |repo, scopes| sprintf("%-100s %s", repo, scopes.join(", ")) }.sort.join("\n")
yaml.delete_if { |k| unused.key?(k) }
File.write("grammars.yml", YAML.dump(yaml))