mdlint 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.pre-commit-hooks.yaml +6 -0
- data/CHANGELOG.md +33 -0
- data/README.md +136 -4
- data/Rakefile +14 -0
- data/Steepfile +17 -0
- data/action.yml +54 -0
- data/benchmark/compare.rb +49 -0
- data/benchmark/format.rb +29 -0
- data/lib/mdlint/cache_store.rb +85 -0
- data/lib/mdlint/cli/output_formatter.rb +150 -0
- data/lib/mdlint/cli.rb +268 -106
- data/lib/mdlint/config.rb +87 -1
- data/lib/mdlint/dialect.rb +53 -0
- data/lib/mdlint/linter/directive_filter.rb +91 -0
- data/lib/mdlint/linter/rule.rb +25 -5
- data/lib/mdlint/linter/rule_engine.rb +44 -7
- data/lib/mdlint/linter/rules/code_block_syntax.rb +128 -0
- data/lib/mdlint/linter/rules/first_line_heading.rb +10 -3
- data/lib/mdlint/linter/rules/heading_increment.rb +4 -3
- data/lib/mdlint/linter/rules/heading_style.rb +24 -2
- data/lib/mdlint/linter/rules/japanese.rb +201 -0
- data/lib/mdlint/linter/rules/line_length.rb +37 -0
- data/lib/mdlint/linter/rules/link_check.rb +151 -0
- data/lib/mdlint/linter/rules/no_multiple_blanks.rb +1 -0
- data/lib/mdlint/linter/rules/no_trailing_spaces.rb +1 -0
- data/lib/mdlint/linter/rules/source_style.rb +317 -0
- data/lib/mdlint/linter/violation.rb +16 -1
- data/lib/mdlint/linter.rb +9 -3
- data/lib/mdlint/lsp.rb +176 -0
- data/lib/mdlint/parallel_runner.rb +42 -0
- data/lib/mdlint/parser/block_parser.rb +627 -50
- data/lib/mdlint/parser/inline_parser.rb +259 -27
- data/lib/mdlint/parser/state.rb +21 -2
- data/lib/mdlint/parser.rb +5 -5
- data/lib/mdlint/plugin.rb +31 -0
- data/lib/mdlint/renderer/html_renderer.rb +346 -0
- data/lib/mdlint/renderer/md_renderer.rb +147 -11
- data/lib/mdlint/renderer.rb +5 -0
- data/lib/mdlint/text_width.rb +39 -0
- data/lib/mdlint/toc.rb +80 -0
- data/lib/mdlint/token.rb +3 -1
- data/lib/mdlint/version.rb +1 -1
- data/lib/mdlint.rb +25 -5
- data/script/commonmark_compatibility.rb +24 -0
- data/script/fetch_commonmark_spec.rb +14 -0
- data/sig/internal.rbs +405 -0
- data/sig/mdlint.rbs +107 -0
- metadata +26 -2
data/lib/mdlint/toc.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mdlint
|
|
4
|
+
module Toc
|
|
5
|
+
START_MARKERS = ["<!-- toc -->", "<!-- toc:start -->"].freeze
|
|
6
|
+
END_MARKERS = ["<!-- toc -->", "<!-- toc:end -->"].freeze
|
|
7
|
+
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def update(source, options = {})
|
|
11
|
+
eol = source.include?("\r\n") ? "\r\n" : "\n"
|
|
12
|
+
normalized_source = source.gsub("\r\n", "\n")
|
|
13
|
+
lines = normalized_source.split("\n", -1)
|
|
14
|
+
heading_tokens = Parser.parse(normalized_source, options)
|
|
15
|
+
entries = table_of_contents(heading_tokens)
|
|
16
|
+
replacement = entries.join("\n")
|
|
17
|
+
marker_pairs(lines).reverse_each do |pair|
|
|
18
|
+
start_index = pair.fetch(0)
|
|
19
|
+
end_index = pair.fetch(1)
|
|
20
|
+
lines[(start_index + 1)...end_index] = replacement.empty? ? [] : replacement.lines(chomp: true)
|
|
21
|
+
end
|
|
22
|
+
lines.join(eol)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def table_of_contents(tokens)
|
|
26
|
+
counts = Hash.new(0)
|
|
27
|
+
tokens.each_with_index.filter_map do |token, index|
|
|
28
|
+
next unless token.type == :heading_open
|
|
29
|
+
|
|
30
|
+
inline = tokens[(index + 1)..]&.find { |candidate| candidate.type == :inline }
|
|
31
|
+
title = inline&.content.to_s.strip
|
|
32
|
+
slug = slugify(title, counts)
|
|
33
|
+
next if title.empty? || slug.empty?
|
|
34
|
+
|
|
35
|
+
level = token.tag.to_s.delete_prefix("h").to_i
|
|
36
|
+
"#{" " * [level - 1, 0].max}- [#{title}](##{slug})"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def marker_pairs(lines)
|
|
41
|
+
pairs = []
|
|
42
|
+
index = 0
|
|
43
|
+
while index < lines.length
|
|
44
|
+
marker = lines[index].strip.downcase
|
|
45
|
+
if marker == "<!-- toc:start -->"
|
|
46
|
+
ending = lines[(index + 1)..]&.index { |line| line.strip.downcase == "<!-- toc:end -->" }
|
|
47
|
+
if ending
|
|
48
|
+
pairs << [index, index + ending + 1]
|
|
49
|
+
index += ending + 1
|
|
50
|
+
end
|
|
51
|
+
elsif marker == "<!-- toc -->"
|
|
52
|
+
ending = lines[(index + 1)..]&.index { |line| line.strip.downcase == "<!-- toc -->" }
|
|
53
|
+
if ending
|
|
54
|
+
pairs << [index, index + ending + 1]
|
|
55
|
+
index += ending + 1
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
index += 1
|
|
59
|
+
end
|
|
60
|
+
pairs
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def slugify(value, counts)
|
|
64
|
+
base = value.gsub(/[`*_~\[\]()<>]/, "")
|
|
65
|
+
.downcase
|
|
66
|
+
.gsub(/[^\p{Alnum}\p{Han}\p{Hiragana}\p{Katakana}\p{Hangul}\s-]/, "")
|
|
67
|
+
.strip
|
|
68
|
+
.gsub(/\s+/, "-")
|
|
69
|
+
suffix = counts[base]
|
|
70
|
+
counts[base] += 1
|
|
71
|
+
suffix.zero? ? base : "#{base}-#{suffix}"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class << self
|
|
76
|
+
def update_toc(source, options = {})
|
|
77
|
+
Toc.update(source, options)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/lib/mdlint/token.rb
CHANGED
|
@@ -47,7 +47,7 @@ module Mdlint
|
|
|
47
47
|
list_item_open list_item_close
|
|
48
48
|
blockquote_open blockquote_close
|
|
49
49
|
code_block fence
|
|
50
|
-
hr html_block
|
|
50
|
+
hr html_block front_matter table directive math_block footnote_definition
|
|
51
51
|
inline
|
|
52
52
|
].freeze
|
|
53
53
|
|
|
@@ -55,6 +55,8 @@ module Mdlint
|
|
|
55
55
|
text
|
|
56
56
|
strong_open strong_close
|
|
57
57
|
em_open em_close
|
|
58
|
+
s_open s_close
|
|
59
|
+
math_inline footnote_ref
|
|
58
60
|
code_inline
|
|
59
61
|
link_open link_close
|
|
60
62
|
image
|
data/lib/mdlint/version.rb
CHANGED
data/lib/mdlint.rb
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "mdlint/version"
|
|
4
|
+
require_relative "mdlint/dialect"
|
|
5
|
+
require_relative "mdlint/text_width"
|
|
6
|
+
require_relative "mdlint/parallel_runner"
|
|
7
|
+
require_relative "mdlint/cache_store"
|
|
4
8
|
require_relative "mdlint/token"
|
|
5
9
|
require_relative "mdlint/parser"
|
|
6
10
|
require_relative "mdlint/renderer"
|
|
7
11
|
require_relative "mdlint/linter"
|
|
12
|
+
require_relative "mdlint/renderer/html_renderer"
|
|
13
|
+
require_relative "mdlint/lsp"
|
|
14
|
+
require_relative "mdlint/toc"
|
|
8
15
|
|
|
9
16
|
module Mdlint
|
|
10
17
|
class Error < StandardError; end
|
|
11
18
|
|
|
12
19
|
class << self
|
|
13
20
|
def format(src, options = {})
|
|
14
|
-
tokens = Parser.parse(src)
|
|
15
|
-
Renderer.render(tokens, options)
|
|
21
|
+
tokens = Parser.parse(src, options)
|
|
22
|
+
formatted = Renderer.render(tokens, options)
|
|
23
|
+
options[:toc] ? Toc.update(formatted, options) : formatted
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def html(src, options = {})
|
|
27
|
+
Renderer.render_html(Parser.parse(src, options), options)
|
|
16
28
|
end
|
|
17
29
|
|
|
18
30
|
def format_file(path, options = {})
|
|
@@ -27,8 +39,12 @@ module Mdlint
|
|
|
27
39
|
end
|
|
28
40
|
end
|
|
29
41
|
|
|
30
|
-
def parse(src)
|
|
31
|
-
Parser.parse(src)
|
|
42
|
+
def parse(src, options = {})
|
|
43
|
+
Parser.parse(src, options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def fix(src, options = {})
|
|
47
|
+
Linter.fix(src, options)
|
|
32
48
|
end
|
|
33
49
|
|
|
34
50
|
def lint(src, options = {})
|
|
@@ -37,7 +53,11 @@ module Mdlint
|
|
|
37
53
|
|
|
38
54
|
def lint_file(path, options = {})
|
|
39
55
|
src = File.read(path)
|
|
40
|
-
lint(src, options)
|
|
56
|
+
lint(src, options.merge(filename: path))
|
|
41
57
|
end
|
|
42
58
|
end
|
|
43
59
|
end
|
|
60
|
+
|
|
61
|
+
require_relative "mdlint/plugin"
|
|
62
|
+
|
|
63
|
+
require_relative "mdlint/plugin"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require_relative "../lib/mdlint"
|
|
5
|
+
|
|
6
|
+
path = ARGV.fetch(0, "spec/fixtures/commonmark_smoke.json")
|
|
7
|
+
strict = ARGV.include?("--strict")
|
|
8
|
+
fixtures = JSON.parse(File.read(path))
|
|
9
|
+
exact = 0
|
|
10
|
+
crashes = []
|
|
11
|
+
|
|
12
|
+
fixtures.each do |fixture|
|
|
13
|
+
actual = Mdlint.html(fixture.fetch("markdown"))
|
|
14
|
+
exact += 1 if actual == fixture.fetch("html")
|
|
15
|
+
rescue StandardError => error
|
|
16
|
+
crashes << { example: fixture["example"], error: "#{error.class}: #{error.message}" }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
total = fixtures.length
|
|
20
|
+
percentage = total.zero? ? 100.0 : exact.fdiv(total) * 100
|
|
21
|
+
puts format("CommonMark fixtures: %d/%d exact (%.2f%%), %d crashes", exact, total, percentage, crashes.length)
|
|
22
|
+
crashes.each { |crash| warn "CRASH #{crash[:example]}: #{crash[:error]}" }
|
|
23
|
+
|
|
24
|
+
exit 1 unless crashes.empty? && (!strict || exact == total)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "net/http"
|
|
6
|
+
require "uri"
|
|
7
|
+
|
|
8
|
+
url = URI(ENV.fetch("COMMONMARK_SPEC_URL", "https://spec.commonmark.org/0.31.2/spec.json"))
|
|
9
|
+
destination = ARGV.fetch(0, "spec/fixtures/commonmark.json")
|
|
10
|
+
body = Net::HTTP.get(url)
|
|
11
|
+
fixtures = JSON.parse(body)
|
|
12
|
+
FileUtils.mkdir_p(File.dirname(destination)) unless File.dirname(destination) == "."
|
|
13
|
+
File.write(destination, JSON.pretty_generate(fixtures) + "\n")
|
|
14
|
+
puts "Wrote #{fixtures.length} CommonMark examples to #{destination}"
|
data/sig/internal.rbs
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# Dynamic implementation boundaries. The public API remains precisely typed in
|
|
2
|
+
# mdlint.rbs; parser and rule extension points intentionally accept arbitrary
|
|
3
|
+
# option hashes and plugin-defined subclasses.
|
|
4
|
+
|
|
5
|
+
module Mdlint
|
|
6
|
+
module TextWidth
|
|
7
|
+
def self.measure: (untyped text) -> Integer
|
|
8
|
+
def self.take: (untyped text, untyped maximum) -> String
|
|
9
|
+
def self.wide?: (untyped codepoint) -> bool
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module Toc
|
|
13
|
+
def update: (untyped source, ?untyped options) -> String
|
|
14
|
+
def table_of_contents: (untyped tokens) -> Array[String]
|
|
15
|
+
def marker_pairs: (untyped lines) -> Array[Array[Integer]]
|
|
16
|
+
def slugify: (untyped value, untyped counts) -> String
|
|
17
|
+
def self.table_of_contents: (untyped tokens) -> Array[String]
|
|
18
|
+
def self.marker_pairs: (untyped lines) -> Array[Array[Integer]]
|
|
19
|
+
def self.slugify: (untyped value, untyped counts) -> String
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class CacheStore
|
|
23
|
+
def initialize: (untyped path) -> void
|
|
24
|
+
def key: (untyped source, untyped options) -> String
|
|
25
|
+
def fetch: (untyped key) -> untyped
|
|
26
|
+
def store: (untyped key, untyped violations) -> void
|
|
27
|
+
def save: () -> void
|
|
28
|
+
def load_data: () -> untyped
|
|
29
|
+
def canonicalize: (untyped value) -> untyped
|
|
30
|
+
def symbolize: (untyped value) -> untyped
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Config
|
|
34
|
+
def load: () -> untyped
|
|
35
|
+
def merge: (untyped cli_options) -> untyped
|
|
36
|
+
def find_config_file: () -> String?
|
|
37
|
+
def load_config_file: (untyped path) -> untyped
|
|
38
|
+
def normalize_options: (untyped parsed) -> untyped
|
|
39
|
+
def normalize_rules: (untyped rules) -> untyped
|
|
40
|
+
def normalize_wrap: (untyped value) -> untyped
|
|
41
|
+
def normalize_command_map: (untyped value) -> untyped
|
|
42
|
+
def normalize_timeout: (untyped value) -> Integer
|
|
43
|
+
def merge_options: (untyped file_options) -> untyped
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module Plugin
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
module Renderer
|
|
50
|
+
class MdRenderer
|
|
51
|
+
def initialize: (?untyped options) -> void
|
|
52
|
+
def render: (untyped tokens) -> String
|
|
53
|
+
def apply_end_of_line: (untyped text) -> String
|
|
54
|
+
def collect_reference_definitions: (untyped tokens) -> untyped
|
|
55
|
+
def append_reference_definitions: (untyped output) -> untyped
|
|
56
|
+
def render_tokens: (untyped tokens, untyped output) -> untyped
|
|
57
|
+
def render_heading: (untyped tokens, untyped start_index, untyped output) -> untyped
|
|
58
|
+
def render_paragraph: (untyped tokens, untyped start_index, untyped output) -> untyped
|
|
59
|
+
def wrap_text: (untyped text) -> String
|
|
60
|
+
def wrap_at_width: (untyped text, untyped width) -> String
|
|
61
|
+
def split_to_width: (untyped text, untyped width) -> Array[String]
|
|
62
|
+
def render_bullet_list: (untyped tokens, untyped start_index, untyped output) -> untyped
|
|
63
|
+
def render_ordered_list: (untyped tokens, untyped start_index, untyped output) -> untyped
|
|
64
|
+
def render_list_item: (untyped tokens, untyped start_index, untyped output, untyped prefix) -> untyped
|
|
65
|
+
def render_table: (untyped token, untyped output) -> untyped
|
|
66
|
+
def render_table_row: (untyped row, untyped widths, untyped alignments) -> String
|
|
67
|
+
def table_separator: (untyped alignment, untyped width) -> String
|
|
68
|
+
def collect_paragraph_content: (untyped tokens, untyped start_index, untyped content_array) -> untyped
|
|
69
|
+
def render_blockquote: (untyped tokens, untyped start_index, untyped output) -> untyped
|
|
70
|
+
def render_fence: (untyped token, untyped output) -> untyped
|
|
71
|
+
def render_code_block: (untyped token, untyped output) -> untyped
|
|
72
|
+
def render_inline: (untyped token) -> String
|
|
73
|
+
def render_inline_tokens: (untyped tokens) -> String
|
|
74
|
+
def find_close_token: (untyped tokens, untyped start_index, untyped close_type) -> untyped
|
|
75
|
+
def format_link_url: (untyped url) -> String
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class HtmlRenderer
|
|
79
|
+
def initialize: (?untyped options) -> void
|
|
80
|
+
def render: (untyped tokens) -> String
|
|
81
|
+
def render_sequence: (untyped tokens, untyped index, ?untyped closing_type) -> untyped
|
|
82
|
+
def render_until_inline: (untyped tokens, untyped index, untyped closing_type) -> untyped
|
|
83
|
+
def render_inline: (untyped token) -> String
|
|
84
|
+
def render_inline_tokens: (untyped tokens) -> String
|
|
85
|
+
def render_table: (untyped token) -> String
|
|
86
|
+
def collapse_tight_item: (untyped item) -> String
|
|
87
|
+
def collect_reference_definitions: (untyped tokens) -> untyped
|
|
88
|
+
def render_footnotes: () -> String
|
|
89
|
+
def render_footnote_content: (untyped content) -> String
|
|
90
|
+
def render_directive: (untyped token) -> String
|
|
91
|
+
def render_cell: (untyped value) -> String
|
|
92
|
+
def image_alt: (untyped value) -> String
|
|
93
|
+
def fenced_code: (untyped token) -> String
|
|
94
|
+
def task_checkbox: (untyped checked) -> String
|
|
95
|
+
def find_close: (untyped tokens, untyped index, untyped close_type) -> untyped
|
|
96
|
+
def reference_literal: (untyped token, untyped inner_tokens) -> String
|
|
97
|
+
def escape: (untyped value) -> String
|
|
98
|
+
def escape_attribute: (untyped value) -> String
|
|
99
|
+
def escape_url_attribute: (untyped value, ?unescape: bool) -> String
|
|
100
|
+
def escape_raw: (untyped value) -> String
|
|
101
|
+
def decode_entities: (untyped value) -> String
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
module Parser
|
|
106
|
+
def self.parse_inline_tokens: (untyped tokens, untyped options) -> untyped
|
|
107
|
+
|
|
108
|
+
class State
|
|
109
|
+
attr_accessor tokens: untyped
|
|
110
|
+
attr_reader raw_lines: untyped
|
|
111
|
+
def initialize: (untyped src) -> void
|
|
112
|
+
def eof?: () -> bool
|
|
113
|
+
def current_line: () -> untyped
|
|
114
|
+
def raw_line: () -> untyped
|
|
115
|
+
def next_line: () -> untyped
|
|
116
|
+
def skip_blank_lines: () -> untyped
|
|
117
|
+
def blank_line?: (?untyped line_num) -> bool
|
|
118
|
+
def remaining_lines: () -> untyped
|
|
119
|
+
def peek_line: (?untyped offset) -> untyped
|
|
120
|
+
def build_line_offsets: () -> untyped
|
|
121
|
+
def expand_tabs: (untyped line) -> String
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
class BlockParser
|
|
125
|
+
def initialize: (?untyped options) -> void
|
|
126
|
+
def parse: (untyped src) -> untyped
|
|
127
|
+
def parse_block: (untyped state) -> untyped
|
|
128
|
+
def parse_directive: (untyped state) -> untyped
|
|
129
|
+
def find_directive_closing_line: (untyped state, untyped name) -> untyped
|
|
130
|
+
def parse_math_block: (untyped state) -> untyped
|
|
131
|
+
def parse_table: (untyped state) -> untyped
|
|
132
|
+
def table_delimiter?: (untyped line) -> bool
|
|
133
|
+
def table_row?: (untyped line) -> bool
|
|
134
|
+
def split_table_row: (untyped line) -> untyped
|
|
135
|
+
def table_alignment: (untyped cell) -> untyped
|
|
136
|
+
def parse_front_matter: (untyped state) -> untyped
|
|
137
|
+
def front_matter_markers: (untyped opener) -> untyped
|
|
138
|
+
def parse_blank_line: (untyped state) -> untyped
|
|
139
|
+
def parse_atx_heading: (untyped state) -> untyped
|
|
140
|
+
def parse_setext_heading: (untyped state) -> untyped
|
|
141
|
+
def parse_fence: (untyped state) -> untyped
|
|
142
|
+
def fence_match: (untyped line) -> untyped
|
|
143
|
+
def parse_hr: (untyped state) -> untyped
|
|
144
|
+
def parse_blockquote: (untyped state) -> untyped
|
|
145
|
+
def parse_bullet_list: (untyped state) -> untyped
|
|
146
|
+
def parse_ordered_list: (untyped state) -> untyped
|
|
147
|
+
def parse_list_items: (untyped state, untyped pattern, untyped marker, ?untyped base_indent) -> untyped
|
|
148
|
+
def parse_ordered_list_items: (untyped state, untyped delimiter, ?untyped base_indent) -> untyped
|
|
149
|
+
def dedent_list_line: (untyped line, untyped base_indent) -> String
|
|
150
|
+
def append_nested_tokens: (untyped state, untyped nested_lines, untyped start_line) -> untyped
|
|
151
|
+
def block_boundary?: (untyped line) -> bool
|
|
152
|
+
def collect_loose_item_content: (untyped state, untyped pattern, untyped base_indent, ?untyped nested_lines, ?untyped content_indent) -> untyped
|
|
153
|
+
def append_loose_paragraph: (untyped state, untyped content, untyped start_line) -> untyped
|
|
154
|
+
def mark_current_list_loose: (untyped state) -> untyped
|
|
155
|
+
def parse_html_block: (untyped state) -> untyped
|
|
156
|
+
def html_block_start?: (untyped line) -> bool
|
|
157
|
+
def lazy_blockquote_continuation?: (untyped line) -> bool
|
|
158
|
+
def parse_code_block: (untyped state) -> untyped
|
|
159
|
+
def parse_reference_definition: (untyped state) -> untyped
|
|
160
|
+
def reference_definition_candidate?: (untyped state) -> bool
|
|
161
|
+
def normalize_reference_label: (untyped label) -> String
|
|
162
|
+
def parse_reference_tail: (untyped tail) -> untyped
|
|
163
|
+
def parse_reference_title: (untyped value) -> untyped
|
|
164
|
+
def parse_footnote_definition: (untyped state) -> untyped
|
|
165
|
+
def parse_paragraph: (untyped state) -> untyped
|
|
166
|
+
def strip_code_indent: (untyped raw_line, untyped expanded_line) -> String
|
|
167
|
+
def front_matter_payload?: (untyped format, untyped lines) -> bool
|
|
168
|
+
def strip_fence_indent: (untyped raw_line, untyped indent) -> String
|
|
169
|
+
def task_attributes: (untyped content) -> untyped
|
|
170
|
+
def strip_task_marker: (untyped content) -> untyped
|
|
171
|
+
def alert_attributes: (untyped content_lines) -> untyped
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
class InlineParser
|
|
175
|
+
def initialize: (?untyped options) -> void
|
|
176
|
+
def parse: (untyped content) -> untyped
|
|
177
|
+
def parse_inline: (untyped content, untyped tokens) -> untyped
|
|
178
|
+
def inline_link_match: (untyped value, ?image: bool) -> untyped
|
|
179
|
+
def parse_link_destination: (untyped value) -> untyped
|
|
180
|
+
def find_unescaped: (untyped value, untyped character, untyped start) -> untyped
|
|
181
|
+
def code_span_match: (untyped value) -> untyped
|
|
182
|
+
def emphasis_match: (untyped value, untyped delimiter, previous: untyped, ?strong: bool) -> untyped
|
|
183
|
+
def delimiter_open?: (untyped delimiter, untyped before, untyped after) -> bool
|
|
184
|
+
def delimiter_close?: (untyped delimiter, untyped before, untyped after) -> bool
|
|
185
|
+
def whitespace_character?: (untyped character) -> bool
|
|
186
|
+
def punctuation_character?: (untyped character) -> bool
|
|
187
|
+
def flush_text: (untyped buffer, untyped tokens) -> untyped
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
class ParallelRunner
|
|
192
|
+
def self.map: (untyped items, jobs: untyped) { (untyped item) -> untyped } -> untyped
|
|
193
|
+
def self.process_queue: (untyped queue, untyped results, untyped errors) { (untyped item) -> untyped } -> untyped
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
class CLI
|
|
197
|
+
def initialize: (untyped argv) -> void
|
|
198
|
+
def run: () -> untyped
|
|
199
|
+
def extract_command: () -> untyped
|
|
200
|
+
def parse_options: () -> untyped
|
|
201
|
+
def load_config: () -> untyped
|
|
202
|
+
def load_plugins: () -> untyped
|
|
203
|
+
def process_format: () -> untyped
|
|
204
|
+
def process_format_stdin: () -> untyped
|
|
205
|
+
def process_format_file: (untyped file) -> untyped
|
|
206
|
+
def process_lint: () -> untyped
|
|
207
|
+
def write_auto_gen_config: (untyped entries) -> untyped
|
|
208
|
+
def process_lint_stdin: () -> untyped
|
|
209
|
+
def process_lint_file: (untyped file) -> untyped
|
|
210
|
+
def cached_lint: (untyped file, untyped source) -> untyped
|
|
211
|
+
def apply_lint_fix: (untyped filename, untyped source, untyped path) -> untyped
|
|
212
|
+
def fix_requested?: () -> bool
|
|
213
|
+
def lint_output: (untyped entries) -> String
|
|
214
|
+
def fail_for?: (untyped entries) -> bool
|
|
215
|
+
def show_rule_list: () -> untyped
|
|
216
|
+
def show_rule_explanation: (untyped rule_id) -> untyped
|
|
217
|
+
def collect_files: (untyped paths) -> untyped
|
|
218
|
+
def excluded?: (untyped file) -> bool
|
|
219
|
+
def show_diff: (untyped filename, untyped original, untyped formatted) -> untyped
|
|
220
|
+
def format_options: () -> untyped
|
|
221
|
+
def lint_options: (?untyped filename) -> untyped
|
|
222
|
+
def split_rules: (untyped value) -> untyped
|
|
223
|
+
def add_code_block_command: (untyped key, untyped specification) -> untyped
|
|
224
|
+
def parse_wrap_mode: (untyped mode) -> untyped
|
|
225
|
+
def parse_level: (untyped level) -> untyped
|
|
226
|
+
|
|
227
|
+
class OutputFormatter
|
|
228
|
+
def initialize: (untyped format) -> void
|
|
229
|
+
def render: (untyped entries) -> String
|
|
230
|
+
def text: (untyped entries) -> String
|
|
231
|
+
def json: (untyped entries) -> String
|
|
232
|
+
def github: (untyped entries) -> String
|
|
233
|
+
def sarif: (untyped entries) -> String
|
|
234
|
+
def checkstyle: (untyped entries) -> String
|
|
235
|
+
def junit: (untyped entries) -> String
|
|
236
|
+
def reviewdog: (untyped entries) -> String
|
|
237
|
+
def xml_escape: (untyped value) -> String
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
module Linter
|
|
242
|
+
class Rule
|
|
243
|
+
attr_reader violations: untyped
|
|
244
|
+
def self.rule_id: () -> untyped
|
|
245
|
+
def self.rule_id=: (untyped value) -> untyped
|
|
246
|
+
def self.description: () -> untyped
|
|
247
|
+
def self.description=: (untyped value) -> untyped
|
|
248
|
+
def self.aliases: () -> untyped
|
|
249
|
+
def self.aliases=: (untyped value) -> untyped
|
|
250
|
+
def self.preset: () -> untyped
|
|
251
|
+
def self.preset=: (untyped value) -> untyped
|
|
252
|
+
def self.inherited: (untyped subclass) -> untyped
|
|
253
|
+
def add_violation: (message: String, line: Integer, ?column: Integer?, ?fixable: bool) -> untyped
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
class RuleRegistry
|
|
257
|
+
def self.clear: () -> untyped
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
class RuleEngine
|
|
261
|
+
def initialize: (?untyped options) -> void
|
|
262
|
+
def check: (untyped tokens, untyped source) -> untyped
|
|
263
|
+
def fix: (untyped tokens, untyped source) -> untyped
|
|
264
|
+
def active_rules: () -> untyped
|
|
265
|
+
def configured_enabled?: (untyped rule_class) -> bool
|
|
266
|
+
def explicitly_configured?: (untyped rule_class) -> bool
|
|
267
|
+
def rule_options: (untyped rule_class) -> untyped
|
|
268
|
+
def rule_setting: (untyped rule_class) -> untyped
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
class DirectiveFilter
|
|
272
|
+
def self.apply: (untyped violations, untyped source) -> untyped
|
|
273
|
+
def initialize: (untyped source) -> void
|
|
274
|
+
def filter: (untyped violations) -> untyped
|
|
275
|
+
def scan: (untyped source) -> untyped
|
|
276
|
+
def apply_directive: (untyped directive, untyped disabled, untyped next_line, untyped line_number) -> untyped
|
|
277
|
+
def normalize_ids: (untyped value) -> untyped
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
class Violation
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
module Rules
|
|
284
|
+
module SourceStyleSupport
|
|
285
|
+
def lines: (untyped source) -> untyped
|
|
286
|
+
def fenced_lines: (untyped source) -> untyped
|
|
287
|
+
def outside_fence?: (untyped fence_state) -> bool
|
|
288
|
+
def line_is_blank?: (untyped line) -> bool
|
|
289
|
+
def inline_tokens: (untyped tokens) -> untyped
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
module JapaneseHelpers
|
|
293
|
+
def each_inline: (untyped tokens) { (untyped token) -> untyped } -> untyped
|
|
294
|
+
def prose_content: (untyped token) -> String
|
|
295
|
+
def line_for: (untyped token) -> Integer
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
class HeadingStyle < Rule
|
|
299
|
+
end
|
|
300
|
+
class HeadingIncrement < Rule
|
|
301
|
+
end
|
|
302
|
+
class NoTrailingSpaces < Rule
|
|
303
|
+
end
|
|
304
|
+
class NoMultipleBlanks < Rule
|
|
305
|
+
end
|
|
306
|
+
class FirstLineHeading < Rule
|
|
307
|
+
def directive?: (untyped token) -> bool
|
|
308
|
+
end
|
|
309
|
+
class LineLength < Rule
|
|
310
|
+
end
|
|
311
|
+
class LinkCheck < Rule
|
|
312
|
+
def heading_slugs: (untyped tokens) -> untyped
|
|
313
|
+
def check_target: (untyped target, untyped token, untyped image, untyped source) -> untyped
|
|
314
|
+
def check_external_target: (untyped target, untyped token) -> untyped
|
|
315
|
+
def check_fragment: (untyped fragment, untyped token, untyped image, untyped headings) -> untyped
|
|
316
|
+
def add_missing_target: (untyped path, untyped token) -> untyped
|
|
317
|
+
def non_markdown_file?: (untyped path) -> bool
|
|
318
|
+
def slugify: (untyped value) -> String
|
|
319
|
+
end
|
|
320
|
+
class CodeBlockSyntax < Rule
|
|
321
|
+
def line_for: (untyped token) -> Integer
|
|
322
|
+
def syntax_error: (untyped language, untyped content) -> untyped
|
|
323
|
+
def command_error: (untyped command, untyped content) -> untyped
|
|
324
|
+
def command_output: (untyped command, untyped content) -> untyped
|
|
325
|
+
def command_result: (untyped command, untyped content) -> untyped
|
|
326
|
+
end
|
|
327
|
+
class JapaneseSpacing < Rule
|
|
328
|
+
include JapaneseHelpers
|
|
329
|
+
end
|
|
330
|
+
class JapanesePunctuation < Rule
|
|
331
|
+
include JapaneseHelpers
|
|
332
|
+
end
|
|
333
|
+
class JapaneseStyle < Rule
|
|
334
|
+
include JapaneseHelpers
|
|
335
|
+
end
|
|
336
|
+
class JapaneseSentenceLength < Rule
|
|
337
|
+
include JapaneseHelpers
|
|
338
|
+
end
|
|
339
|
+
class JapaneseCommaCount < Rule
|
|
340
|
+
include JapaneseHelpers
|
|
341
|
+
end
|
|
342
|
+
class JapaneseDuplicateParticle < Rule
|
|
343
|
+
include JapaneseHelpers
|
|
344
|
+
end
|
|
345
|
+
class JapaneseWidth < Rule
|
|
346
|
+
include JapaneseHelpers
|
|
347
|
+
end
|
|
348
|
+
class NoHardTabs < Rule
|
|
349
|
+
include SourceStyleSupport
|
|
350
|
+
end
|
|
351
|
+
class NoSpaceAfterHash < Rule
|
|
352
|
+
end
|
|
353
|
+
class NoMultipleSpacesAfterHash < Rule
|
|
354
|
+
end
|
|
355
|
+
class NoMultipleSpacesAfterBlockquote < Rule
|
|
356
|
+
end
|
|
357
|
+
class ListMarkerSpace < Rule
|
|
358
|
+
end
|
|
359
|
+
class FencedCodeBlankLines < Rule
|
|
360
|
+
include SourceStyleSupport
|
|
361
|
+
end
|
|
362
|
+
class ListBlankLines < Rule
|
|
363
|
+
include SourceStyleSupport
|
|
364
|
+
end
|
|
365
|
+
class NoBareUrls < Rule
|
|
366
|
+
include SourceStyleSupport
|
|
367
|
+
end
|
|
368
|
+
class NoSpaceInEmphasis < Rule
|
|
369
|
+
include SourceStyleSupport
|
|
370
|
+
end
|
|
371
|
+
class NoSpaceInCode < Rule
|
|
372
|
+
include SourceStyleSupport
|
|
373
|
+
end
|
|
374
|
+
class FencedCodeStyle < Rule
|
|
375
|
+
include SourceStyleSupport
|
|
376
|
+
end
|
|
377
|
+
class SingleTrailingNewline < Rule
|
|
378
|
+
end
|
|
379
|
+
class EmphasisStyle < Rule
|
|
380
|
+
include SourceStyleSupport
|
|
381
|
+
end
|
|
382
|
+
class StrongStyle < Rule
|
|
383
|
+
include SourceStyleSupport
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
module Lsp
|
|
389
|
+
class Server
|
|
390
|
+
def initialize: (?input: untyped, ?output: untyped) -> void
|
|
391
|
+
def run: () -> untyped
|
|
392
|
+
def read_message: () -> untyped
|
|
393
|
+
def write_message: (untyped message) -> untyped
|
|
394
|
+
def handle_message: (untyped message) -> untyped
|
|
395
|
+
def response: (untyped id, untyped result) -> untyped
|
|
396
|
+
def notification: (untyped method, untyped params) -> untyped
|
|
397
|
+
def update_document: (untyped uri, untyped text) -> untyped
|
|
398
|
+
def formatting_edits: (untyped uri) -> untyped
|
|
399
|
+
def code_actions: (untyped uri) -> untyped
|
|
400
|
+
def publish_diagnostics: (untyped uri) -> untyped
|
|
401
|
+
def full_range: (untyped text) -> untyped
|
|
402
|
+
def uri_path: (untyped uri) -> untyped
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
end
|