mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Improve grammar scripts (#3350)
* Remove trailing spaces * Setup Bundler in some scripts * Update grammar index * Make prune-grammars script to be callable in a script directory * Prune unused xquery grammar repo source.xq by language-jsoniq is actual tm_scope for XQuery. * Remove xquery submodule git submodule deinit vendor/grammars/xquery/ git rm vendor/grammars/xquery/ * Fix invocation of script/list-grammars This fixes #3339. * Make add-grammars script to be callable in a script directory * Generate samples.json before running list-grammars list-grammars requires linguist.
This commit is contained in:
committed by
Brandon Black
parent
581723748b
commit
12f9295dd7
@@ -1,19 +1,20 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "bundler/setup"
|
||||
require "linguist"
|
||||
require "json"
|
||||
require "yaml"
|
||||
|
||||
class GrammarList
|
||||
|
||||
|
||||
ROOT = File.expand_path "../../", __FILE__
|
||||
|
||||
|
||||
def initialize
|
||||
@submodules = load_submodules()
|
||||
@sources = load_sources()
|
||||
@language_names = load_languages()
|
||||
end
|
||||
|
||||
|
||||
# Load .gitmodules
|
||||
def load_submodules
|
||||
submodules = {}
|
||||
@@ -29,14 +30,14 @@ class GrammarList
|
||||
end
|
||||
submodules
|
||||
end
|
||||
|
||||
|
||||
# Grab the name of each language, sorted case-insensitively
|
||||
def load_languages
|
||||
Linguist::Language.all.map(&:name).sort do |a, b|
|
||||
a.downcase() <=> b.downcase()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Load grammars.yml
|
||||
def load_sources
|
||||
sources = {}
|
||||
@@ -46,7 +47,7 @@ class GrammarList
|
||||
end
|
||||
sources
|
||||
end
|
||||
|
||||
|
||||
# Shorten a repository URL
|
||||
def shorten(url)
|
||||
if url =~ /^https?:\/\/(?:www\.)?github\.com\/([^\/]+\/[^\/]+)/i
|
||||
@@ -57,7 +58,7 @@ class GrammarList
|
||||
url.replace(/^https?:\/\/(?:www\.)?/i, "")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Markdown: Generate grammar list
|
||||
def to_markdown
|
||||
markdown = ""
|
||||
@@ -87,7 +88,7 @@ class GrammarList
|
||||
|
||||
markdown
|
||||
end
|
||||
|
||||
|
||||
# Update the file displaying the reader-friendly list of grammar repos
|
||||
def update_readme
|
||||
readme = "#{ROOT}/vendor/README.md"
|
||||
|
||||
Reference in New Issue
Block a user