source2md 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/doc/0110_code_small.rb +4 -2
- data/examples/type_partial_code.rb +26 -3
- data/lib/source2md/cli.rb +11 -9
- data/lib/source2md/formatter/type_partial_code.rb +11 -1
- data/lib/source2md/generator.rb +2 -0
- data/lib/source2md/version.rb +1 -1
- data/lib/source2md.rb +2 -1
- data/spec/formatter/type_partial_code_spec.rb +5 -1
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3477e280893742563cabf28b242a48d0efdc0943294c902a0fd7085950213b6a
|
4
|
+
data.tar.gz: 6a0c6f3b324fe3cd6b6d6e9fd1c038fba91dcbaf3aff742cf8f80ef2129c49a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be3fb7b9ef5f24186a2b613fd10d42d5d0bbad7781d99b9ac72251dda336b13d50737febd993f6d5ecfc0dfe83fb87930c317b3dc21475afe593e1fecea5173b
|
7
|
+
data.tar.gz: 0e68f783920b8abb32a1e405cecc4f0f881cf9bc71f4b3b2f13fff444b8272b8361d37389f10c4085b55be51c67a439d6ddbc5061bda776a4255797a9ecf1cd3
|
data/README.md
CHANGED
data/doc/0110_code_small.rb
CHANGED
@@ -11,6 +11,7 @@ puts Source2MD::Section.new(<<~EOS).to_md
|
|
11
11
|
"Hello, world!"
|
12
12
|
}
|
13
13
|
|
14
|
+
#+code_block_name: (name)
|
14
15
|
hello.call
|
15
16
|
EOS
|
16
17
|
#+END_SRC
|
@@ -21,9 +22,10 @@ EOS
|
|
21
22
|
# > }
|
22
23
|
# > ```
|
23
24
|
|
24
|
-
# > ```ruby
|
25
|
+
# > ```ruby:(name)
|
25
26
|
# > hello.call
|
26
27
|
# > ```
|
28
|
+
|
27
29
|
# >> ```ruby
|
28
30
|
# >> hello = -> {
|
29
31
|
# >> "Hello, world!"
|
@@ -31,6 +33,6 @@ EOS
|
|
31
33
|
# >> ```
|
32
34
|
# >>
|
33
35
|
# >>
|
34
|
-
# >> ```ruby
|
36
|
+
# >> ```ruby:(name)
|
35
37
|
# >> hello.call
|
36
38
|
# >> ```
|
@@ -1,26 +1,49 @@
|
|
1
1
|
#+hidden: true
|
2
2
|
require "./setup"
|
3
3
|
|
4
|
+
Source2MD.data_block_exclude = true
|
5
|
+
|
4
6
|
puts Source2MD::Element.new(<<~EOS).to_md
|
7
|
+
#+code_block_name: foo
|
5
8
|
a
|
6
9
|
b
|
7
10
|
c
|
11
|
+
__END__
|
12
|
+
foo
|
8
13
|
EOS
|
14
|
+
# >> head: {"code_block_name"=>"foo"}
|
15
|
+
# >> body: "a\n b\nc\n__END__\nfoo\n"
|
16
|
+
# >> Source2MD::Formatter::TypeHidden => false
|
17
|
+
# >> Source2MD::Formatter::TypeCodeInclude =>
|
18
|
+
# >> Source2MD::Formatter::TypeRawInclude =>
|
19
|
+
# >> Source2MD::Formatter::TypeParseInclude =>
|
20
|
+
# >> Source2MD::Formatter::TypeTitle => false
|
21
|
+
# >> Source2MD::Formatter::TypeWarn =>
|
22
|
+
# >> Source2MD::Formatter::TypeAlert =>
|
23
|
+
# >> Source2MD::Formatter::TypeMethod =>
|
24
|
+
# >> Source2MD::Formatter::TypeTable => false
|
25
|
+
# >> Source2MD::Formatter::TypeSourceBlock => false
|
26
|
+
# >> Source2MD::Formatter::TypeText => false
|
27
|
+
# >> Source2MD::Formatter::TypePartialCode => true
|
9
28
|
# >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypePartialCode
|
10
|
-
# >> > {}
|
29
|
+
# >> > {"code_block_name"=>"foo"}
|
11
30
|
# >> > ------------------------------------------------------------ in
|
12
31
|
# >> > a
|
13
32
|
# >> > b
|
14
33
|
# >> > c
|
34
|
+
# >> > __END__
|
35
|
+
# >> > foo
|
36
|
+
# >> >
|
15
37
|
# >> >
|
16
38
|
# >> > ------------------------------------------------------------ out
|
17
|
-
# >> > ```ruby
|
39
|
+
# >> > ```ruby:foo
|
18
40
|
# >> > a
|
19
41
|
# >> > b
|
20
42
|
# >> > c
|
21
43
|
# >> > ```
|
44
|
+
# >> >
|
22
45
|
# >> > ------------------------------------------------------------
|
23
|
-
# >> ```ruby
|
46
|
+
# >> ```ruby:foo
|
24
47
|
# >> a
|
25
48
|
# >> b
|
26
49
|
# >> c
|
data/lib/source2md/cli.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Source2MD
|
2
2
|
class Cli < Thor
|
3
|
-
class_option :debug,
|
4
|
-
class_option :xmp_out_exclude,
|
5
|
-
class_option :
|
6
|
-
class_option :
|
7
|
-
class_option :
|
8
|
-
class_option :
|
3
|
+
class_option :debug, type: :boolean, aliases: "-d", default: false
|
4
|
+
class_option :xmp_out_exclude, type: :boolean, aliases: "-x", default: false
|
5
|
+
class_option :data_block_exclude, type: :boolean, default: false
|
6
|
+
class_option :readonly, type: :boolean, aliases: "-r", default: true
|
7
|
+
class_option :default_lang, type: :string, aliases: "-l", default: "ruby"
|
8
|
+
class_option :prefix_re, type: :string
|
9
|
+
class_option :comment_re, type: :string
|
9
10
|
|
10
11
|
def initialize(...)
|
11
12
|
super
|
@@ -15,9 +16,10 @@ module Source2MD
|
|
15
16
|
Source2MD.debug = true
|
16
17
|
end
|
17
18
|
|
18
|
-
Source2MD.xmp_out_exclude
|
19
|
-
Source2MD.
|
20
|
-
Source2MD.
|
19
|
+
Source2MD.xmp_out_exclude = options[:xmp_out_exclude]
|
20
|
+
Source2MD.data_block_exclude = options[:data_block_exclude]
|
21
|
+
Source2MD.readonly = options[:readonly]
|
22
|
+
Source2MD.default_lang = options[:default_lang]
|
21
23
|
|
22
24
|
Source2MD::RE.update do |e|
|
23
25
|
if v = options[:prefix_re]
|
@@ -6,7 +6,17 @@ module Source2MD
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_md
|
9
|
-
CodeBlock.new(element.
|
9
|
+
CodeBlock.new(body, name: element.head["code_block_name"]).to_md
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def body
|
15
|
+
if Source2MD.data_block_exclude
|
16
|
+
element.body.sub(/^__END__\R.*/m, "")
|
17
|
+
else
|
18
|
+
element.body
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
12
22
|
end
|
data/lib/source2md/generator.rb
CHANGED
data/lib/source2md/version.rb
CHANGED
data/lib/source2md.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require "active_support/logger"
|
2
|
-
require "active_support/isolated_execution_state"
|
3
3
|
|
4
4
|
require "active_support/core_ext/hash"
|
5
5
|
require "active_support/core_ext/string"
|
@@ -16,6 +16,7 @@ module Source2MD
|
|
16
16
|
config_accessor(:xmp_out_exclude) { false }
|
17
17
|
config_accessor(:readonly) { true }
|
18
18
|
config_accessor(:default_lang) { "ruby" }
|
19
|
+
config_accessor(:data_block_exclude) { false }
|
19
20
|
end
|
20
21
|
|
21
22
|
require "zeitwerk"
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: source2md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Ikeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
250
|
- !ruby/object:Gem::Version
|
251
251
|
version: '0'
|
252
252
|
requirements: []
|
253
|
-
rubygems_version: 3.4.
|
253
|
+
rubygems_version: 3.4.20
|
254
254
|
signing_key:
|
255
255
|
specification_version: 4
|
256
256
|
summary: Markdown generator from source code
|