elisp2any 0.0.6 → 0.0.7
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/CHANGELOG.md +11 -0
- data/README.md +16 -2
- data/Rakefile +5 -7
- data/exe/elisp2any +28 -4
- data/lib/elisp/comment.rb +15 -76
- data/lib/elisp/default.css +11 -0
- data/lib/elisp/doc_string_parser.rb +96 -0
- data/lib/elisp/heading.rb +31 -0
- data/lib/elisp/parser.rb +23 -50
- data/lib/elisp/version.rb +18 -0
- data/lib/elisp.rb +19 -62
- metadata +7 -26
- data/lib/elisp2any/aside.rb +0 -23
- data/lib/elisp2any/blanklines.rb +0 -20
- data/lib/elisp2any/code.rb +0 -49
- data/lib/elisp2any/codeblock.rb +0 -56
- data/lib/elisp2any/comment.rb +0 -19
- data/lib/elisp2any/commentary.rb +0 -32
- data/lib/elisp2any/expression.rb +0 -90
- data/lib/elisp2any/footer_line.rb +0 -28
- data/lib/elisp2any/header_line.rb +0 -80
- data/lib/elisp2any/heading.rb +0 -68
- data/lib/elisp2any/html_renderer/index.html.erb +0 -23
- data/lib/elisp2any/html_renderer.erb +0 -22
- data/lib/elisp2any/html_renderer.rb +0 -149
- data/lib/elisp2any/inline_code.rb +0 -10
- data/lib/elisp2any/line.rb +0 -52
- data/lib/elisp2any/paragraph.rb +0 -37
- data/lib/elisp2any/section.rb +0 -49
- data/lib/elisp2any/text.rb +0 -33
- data/lib/elisp2any/version.rb +0 -4
- data/lib/elisp2any.rb +0 -26
data/lib/elisp2any/line.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'strscan'
|
|
2
|
-
require 'forwardable'
|
|
3
|
-
require_relative 'inline_code'
|
|
4
|
-
require "elisp2any/comment"
|
|
5
|
-
require "elisp2any/text"
|
|
6
|
-
|
|
7
|
-
module Elisp2any
|
|
8
|
-
class Line
|
|
9
|
-
def self.scan(scanner)
|
|
10
|
-
pos = scanner.pos
|
|
11
|
-
comment = Comment.scan(scanner) or return
|
|
12
|
-
unless comment.colons == 2
|
|
13
|
-
scanner.pos = pos
|
|
14
|
-
return
|
|
15
|
-
end
|
|
16
|
-
unless comment.padding[0] == " "
|
|
17
|
-
raise Error, "line comment should have a whitespace padding"
|
|
18
|
-
end
|
|
19
|
-
content = "#{comment.padding[1..]}#{comment.content}"
|
|
20
|
-
new(Text.scan(content).to_a)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def initialize(chunks) # :nodoc:
|
|
24
|
-
@chunks = chunks
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.parse(string) # :nodoc:
|
|
28
|
-
scanner = StringScanner.new(string)
|
|
29
|
-
chunks = []
|
|
30
|
-
|
|
31
|
-
until scanner.eos?
|
|
32
|
-
if scanner.skip(/`(?<content>[^']+)'/)
|
|
33
|
-
chunks << InlineCode.new(scanner[:content])
|
|
34
|
-
else
|
|
35
|
-
chunk = scanner.getch
|
|
36
|
-
if (last = chunks.last).is_a?(String)
|
|
37
|
-
last << chunk
|
|
38
|
-
else
|
|
39
|
-
chunks << chunk
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
new(chunks)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
extend Forwardable # :nodoc:
|
|
48
|
-
def_delegators :@chunks, :each, :deconstruct
|
|
49
|
-
|
|
50
|
-
include Enumerable
|
|
51
|
-
end
|
|
52
|
-
end
|
data/lib/elisp2any/paragraph.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'forwardable'
|
|
2
|
-
require "elisp2any/line"
|
|
3
|
-
|
|
4
|
-
module Elisp2any
|
|
5
|
-
class Paragraph
|
|
6
|
-
def self.scan(scanner)
|
|
7
|
-
scanner = StringScanner.new(scanner) unless scanner.respond_to?(:skip)
|
|
8
|
-
lines = []
|
|
9
|
-
while (line = Line.scan(scanner))
|
|
10
|
-
lines << line
|
|
11
|
-
end
|
|
12
|
-
lines.empty? and return
|
|
13
|
-
new(:TODO, lines, :TODO)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# TODO: delete
|
|
17
|
-
attr_reader :end_row # :nodoc:
|
|
18
|
-
|
|
19
|
-
# TODO: delete node and end_row
|
|
20
|
-
def initialize(node, lines, end_row) # :nodoc:
|
|
21
|
-
@node = node
|
|
22
|
-
@lines = lines
|
|
23
|
-
@end_row = end_row
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# TODO: delete
|
|
27
|
-
def code?
|
|
28
|
-
false
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
extend Forwardable # :nodoc:
|
|
32
|
-
def_delegators :@lines, :empty?, :clear, :<<, :each, :deconstruct, :size
|
|
33
|
-
def_delegators :@node, :adjucent?
|
|
34
|
-
|
|
35
|
-
include Enumerable
|
|
36
|
-
end
|
|
37
|
-
end
|
data/lib/elisp2any/section.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
require "forwardable"
|
|
2
|
-
require "elisp2any/heading"
|
|
3
|
-
require "elisp2any/blanklines"
|
|
4
|
-
require "elisp2any/text"
|
|
5
|
-
|
|
6
|
-
module Elisp2any
|
|
7
|
-
class Section
|
|
8
|
-
attr_reader :heading,
|
|
9
|
-
# TODO: gather blocks and sections
|
|
10
|
-
:blocks,
|
|
11
|
-
:sections
|
|
12
|
-
|
|
13
|
-
def self.scan(scanner)
|
|
14
|
-
heading = Heading.scan(scanner) or return
|
|
15
|
-
heading.content = Text.scan(heading.content)
|
|
16
|
-
Blanklines.scan(scanner) # optional
|
|
17
|
-
blocks = []
|
|
18
|
-
while (blo = Paragraph.scan(scanner) || Codeblock.scan(scanner))
|
|
19
|
-
blocks << blo
|
|
20
|
-
Blanklines.scan(scanner) # optional
|
|
21
|
-
end
|
|
22
|
-
pos = scanner.pos
|
|
23
|
-
sections = []
|
|
24
|
-
while (section = scan(scanner))
|
|
25
|
-
if section.level == heading.level + 1
|
|
26
|
-
sections << section
|
|
27
|
-
pos = scanner.pos
|
|
28
|
-
elsif section.level >= heading.level + 2
|
|
29
|
-
raise Error, "too demoted heading"
|
|
30
|
-
else
|
|
31
|
-
scanner.pos = pos
|
|
32
|
-
break
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
new(heading:, blocks:, sections:)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def initialize(heading:, blocks:, sections:)
|
|
39
|
-
@heading = heading
|
|
40
|
-
@blocks = blocks
|
|
41
|
-
@sections = sections
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
alias paragraphs blocks # TODO: delete
|
|
45
|
-
|
|
46
|
-
extend Forwardable # :nodoc:
|
|
47
|
-
def_delegator :@heading, :level
|
|
48
|
-
end
|
|
49
|
-
end
|
data/lib/elisp2any/text.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require "forwardable"
|
|
2
|
-
|
|
3
|
-
module Elisp2any
|
|
4
|
-
class Text
|
|
5
|
-
def self.scan(scanner)
|
|
6
|
-
scanner = StringScanner.new(scanner) unless scanner.respond_to?(:skip)
|
|
7
|
-
tokens = []
|
|
8
|
-
until scanner.eos?
|
|
9
|
-
if scanner.skip(/`(?<content>[^']+)'/)
|
|
10
|
-
tokens << { code: scanner[:content] }
|
|
11
|
-
else
|
|
12
|
-
char = scanner.getch
|
|
13
|
-
case tokens
|
|
14
|
-
in [*, String => last]
|
|
15
|
-
last << char
|
|
16
|
-
else
|
|
17
|
-
tokens << char
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
new(tokens)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def initialize(tokens)
|
|
25
|
-
@tokens = tokens
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
extend Forwardable # :nodoc:
|
|
29
|
-
def_delegators :@tokens, :each, :deconstruct
|
|
30
|
-
|
|
31
|
-
include Enumerable
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/elisp2any/version.rb
DELETED
data/lib/elisp2any.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require_relative 'elisp2any/version'
|
|
2
|
-
require_relative 'elisp2any/heading'
|
|
3
|
-
|
|
4
|
-
module Elisp2any
|
|
5
|
-
autoload :HeaderLine, "elisp2any/header_line.rb"
|
|
6
|
-
autoload :Blanklines, "elisp2any/blanklines.rb"
|
|
7
|
-
Error = Class.new(StandardError)
|
|
8
|
-
|
|
9
|
-
def self.scan_filename(scanner) # :nodoc:
|
|
10
|
-
scanner.scan(/[a-z]+[.]el\b/)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.scan_variable(scanner) # :nodoc:
|
|
14
|
-
scanner.scan(/[a-z-]+\b/)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.scan_top_heading(scanner) # :nodoc:
|
|
18
|
-
pos = scanner.pos
|
|
19
|
-
heading = Heading.scan(scanner) or return
|
|
20
|
-
unless heading.level.zero?
|
|
21
|
-
scanner.pos = pos
|
|
22
|
-
return
|
|
23
|
-
end
|
|
24
|
-
heading.content
|
|
25
|
-
end
|
|
26
|
-
end
|