rdoc-markdown 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df97c53443f43093bb4d4d603805cd2fdab86d4b8f22a56e5997657054f71401
4
- data.tar.gz: 75da9383aafa24c2dca008f048d5a833072450e20449c5f239312dc72f9425fd
3
+ metadata.gz: 2bd22f1897418114a7136727481ee4b70001e5b9b6314748da8d09303229812a
4
+ data.tar.gz: 1c82d1b8d074c7d714eeef4dedcffdc2f4f5c007056b98740d2026be621ffa29
5
5
  SHA512:
6
- metadata.gz: 8272fa3b07ada1879d930beb615cc173d4ae69446aa269a92560097f26b68c50449e3088f5933a83f2c8430eac97431bddfc501ebdac69c0ea7b415d501e9dcf
7
- data.tar.gz: 04220f6918002d8026049cce123f80a10bd706e7e727c5d1365b3c9714dd905826b21d99679993345e7e6e9e0f42e8e4c75be3cf8b72863beff4b05bd127223c
6
+ metadata.gz: cb0ce1049d602b43f8fb45cfbe569fbff6ec7c2e14db0ef5cf92bebff696a1817f1f04d5b2648612f16086f830ce7c5b67075e6362a36da2b8e98bd942ab20a2
7
+ data.tar.gz: 4106314ed71d6d0b387c60d9c338e912e646941476c96cf5aee7badb16ab043475d85fdbe907c1df740dc851f2858256ed3edd6e4545e275bc3005d96500c312
data/.editorconfig ADDED
@@ -0,0 +1,13 @@
1
+ # top-most EditorConfig file
2
+ root = true
3
+
4
+ # Unix-style newlines with a newline ending every file
5
+ # Two spaces for indenting
6
+ [*]
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ indent_style = space
10
+ indent_size = 2
11
+ charset = utf-8
12
+ trim_trailing_whitespace = true
13
+ max_line_length = 120
data/.standard.yml CHANGED
@@ -1,3 +1,10 @@
1
1
  # For available configuration options, see:
2
2
  # https://github.com/testdouble/standard
3
- ruby_version: 2.6
3
+ ruby_version: 2.7
4
+ parallel: true
5
+ format: progress
6
+
7
+ ignore:
8
+ - 'docs/example.rb'
9
+ - '**/*':
10
+ - Style/GlobalVars
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rdoc-markdown (0.1.2)
5
+ erb
6
+ rdoc (~> 6.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ cgi (0.3.3)
13
+ erb (2.2.3)
14
+ cgi
15
+ minitest (5.16.3)
16
+ parallel (1.22.1)
17
+ parser (3.1.2.1)
18
+ ast (~> 2.4.1)
19
+ rainbow (3.1.1)
20
+ rake (13.0.6)
21
+ rdiscount (2.2.0.2)
22
+ rdoc (6.2.1.1)
23
+ regexp_parser (2.5.0)
24
+ rexml (3.2.5)
25
+ rubocop (1.29.1)
26
+ parallel (~> 1.10)
27
+ parser (>= 3.1.0.0)
28
+ rainbow (>= 2.2.2, < 4.0)
29
+ regexp_parser (>= 1.8, < 3.0)
30
+ rexml (>= 3.2.5, < 4.0)
31
+ rubocop-ast (>= 1.17.0, < 2.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (>= 1.4.0, < 3.0)
34
+ rubocop-ast (1.21.0)
35
+ parser (>= 3.1.1.0)
36
+ rubocop-performance (1.13.3)
37
+ rubocop (>= 1.7.0, < 2.0)
38
+ rubocop-ast (>= 0.4.0)
39
+ ruby-progressbar (1.11.0)
40
+ standard (1.12.1)
41
+ rubocop (= 1.29.1)
42
+ rubocop-performance (= 1.13.3)
43
+ unicode-display_width (2.3.0)
44
+
45
+ PLATFORMS
46
+ arm64-darwin-21
47
+ x86_64-linux
48
+
49
+ DEPENDENCIES
50
+ bundler
51
+ minitest (~> 5.0)
52
+ rake (~> 13.0)
53
+ rdiscount
54
+ rdoc-markdown!
55
+ standard (~> 1.3)
56
+
57
+ BUNDLED WITH
58
+ 2.3.20
data/README.md CHANGED
@@ -24,6 +24,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
24
24
 
25
25
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
26
 
27
+ ## Release
28
+ ```
29
+ gem build rdoc-markdown.gemspec
30
+ ```
27
31
  ## Contributing
28
32
 
29
33
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rdoc-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rdoc-markdown/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "standard/rake"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.verbose = true
7
+ t.warning = false
8
+ t.test_files = FileList["test/test*.rb"]
9
+ end
10
+
11
+ task default: [:test, "standard:fix"]
data/docs/example.rb ADDED
@@ -0,0 +1,142 @@
1
+ ##
2
+ # === RDoc::Generator::SolarFish example.
3
+ #
4
+ # This example employs variois RDoc features to demonstrate
5
+ # generator output.
6
+ #
7
+ # ---
8
+ #
9
+ # Links:
10
+ #
11
+ # 1. {Project Home Page}[https://github.com/rbdoc/rdoc-generator-solarfish)
12
+ # 2. {RDoc Documentation}[http://ruby-doc.org/stdlib-2.0.0/libdoc/rdoc/rdoc/RDoc/Markup.html]
13
+ #
14
+
15
+ ##
16
+ # A mixin for waterfowl creatures.
17
+ module Waterfowl
18
+ # Swimming helper.
19
+ def swim
20
+ puts 'swimming around'
21
+ end
22
+ end
23
+
24
+ ##
25
+ # The base class for all birds.
26
+ class Bird
27
+ ##
28
+ # Produce some noise.
29
+ #--
30
+ # FIXME: maybe extract this to a base class +Animal+?
31
+ #++
32
+ def speak # :yields: text
33
+ puts 'generic tweeting'
34
+ yield 'tweet'
35
+ yield 'tweet'
36
+ end
37
+
38
+ # Fly somewhere.
39
+ #
40
+ # Flying is the most critical feature of birds.
41
+ #
42
+ # :args: direction, velocity
43
+ #
44
+ # :call-seq:
45
+ # Bird.fly(symbol, number) -> bool
46
+ # Bird.fly(string, number) -> bool
47
+ #
48
+ # = Example
49
+ #
50
+ # fly(:south, 70)
51
+ def fly(direction, velocity)
52
+ _fly_impl(direction, velocity)
53
+ end
54
+
55
+ def _fly_impl(_direction, _velocity) # :nodoc:
56
+ puts "flying away: direction=#{direction}, velocity=#{velocity}"
57
+ end
58
+ end
59
+
60
+ ##
61
+ # A duck is a Waterfowl Bird.
62
+ #
63
+ # Features:
64
+ #
65
+ # bird::
66
+ #
67
+ # * speak
68
+ # * fly
69
+ #
70
+ # waterfowl::
71
+ #
72
+ # * swim
73
+ class Duck
74
+ extend Animal
75
+ include Waterfowl
76
+
77
+ # :section: Bird overrides
78
+
79
+ # Duck overrides generic implementation.
80
+ def speak
81
+ speech = quack
82
+ yield speech
83
+ end
84
+
85
+ # Implements quacking
86
+ def quack
87
+ 'quack'
88
+ end
89
+
90
+ private :quack
91
+
92
+ # :section: Duck extensions
93
+
94
+ # True for domestic ducks.
95
+ attr_accessor :domestic
96
+
97
+ # True for rubber ducks.
98
+ attr_reader :rubber
99
+
100
+ MAX_VELOCITY = 130 # Maximum velocity for a flying duck.
101
+
102
+ ##
103
+ # Global list of all rubber ducks.
104
+ #
105
+ # Use when in trouble.
106
+ @@rubber_ducks = []
107
+
108
+ # Returns list of all rubber ducks.
109
+ def self.rubber_ducks
110
+ @@rubber_ducks
111
+ end
112
+
113
+ # Creates a new duck.
114
+ def initialize(domestic, rubber)
115
+ @domestic = domestic
116
+ @rubber = rubber
117
+ @@rubber_ducks << self if rubber
118
+ end
119
+
120
+ # Checks if this duck is a useful one.
121
+ #
122
+ # :call-seq:
123
+ # Bird.useful? -> bool
124
+ def useful?
125
+ @domestic || @rubber
126
+ end
127
+ end
128
+
129
+ # Default velocity for a flying duck.
130
+ DEFAULT_DUCK_VELOCITY = 70
131
+
132
+ # Default rubber duck.
133
+ #
134
+ # *Note:*
135
+ # Global variables are evil, but rubber ducks are worth it.
136
+ $default_rubber_duck = Duck.new(false, true)
137
+
138
+ # Domestic rubber duck.
139
+ #
140
+ # *Note:*
141
+ # This is weird... Thus not making it global.
142
+ domestic_rubber_duck = Duck.new(true, true)
data/lib/markdown.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rdoc/rdoc"
4
3
  require "rdoc/generator/markdown"
5
- require_relative "rdoc/markdown/version"
6
-
7
- module Markdown
8
4
 
5
+ class RDoc::Markdown
9
6
  end
data/lib/rdoc/discover.rb CHANGED
@@ -1,4 +1 @@
1
- $stderr.puts "Discovered RDoc-Markdown!"
2
-
3
- # RDoc plugin hook
4
- require 'markdown'
1
+ require "markdown"
@@ -1,20 +1,140 @@
1
- gem 'rdoc'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rdoc/rdoc'
4
- require 'rdoc/generator/json_index'
3
+ gem "rdoc"
5
4
 
5
+ require "pathname"
6
+ require "erb"
7
+
8
+ # Markdown generator.
9
+ # Registers command line options and generates markdown files
10
+ # RDoc documentation and options.
6
11
  class RDoc::Generator::Markdown
7
- RDoc::RDoc.add_generator self
12
+ RDoc::RDoc.add_generator self
13
+
14
+ TEMPLATE_DIR = File.expand_path(
15
+ File.join(File.dirname(__FILE__), '..', '..', 'templates'))
16
+
17
+ ##
18
+ # The RDoc::Store that is the source of the generated content
19
+
20
+ attr_reader :store
21
+
22
+ ##
23
+ # The path to generate files into, combined with <tt>--op</tt> from the
24
+ # options for a full path.
25
+
26
+ attr_reader :base_dir
27
+
28
+ ##
29
+ # Classes and modules to be used by this generator, not necessarily
30
+ # displayed. See also #modsort
31
+
32
+ attr_reader :classes
33
+
34
+ ##
35
+ # Files to be displayed by this generator
36
+
37
+ attr_reader :files
38
+
39
+ ##
40
+ # Methods to be displayed by this generator
41
+
42
+ attr_reader :methods
43
+
44
+ ##
45
+ # Sorted list of classes and modules to be displayed by this generator
46
+
47
+ attr_reader :modsort
48
+
49
+ ##
50
+ # Directory where generated class HTML files live relative to the output
51
+ # dir.
52
+
53
+ def class_dir
54
+ nil
55
+ end
56
+
57
+ def initialize(store, options)
58
+ @store = store
59
+ @options = options
60
+
61
+ @base_dir = Pathname.pwd.expand_path
8
62
 
9
- def initialize(store, options)
10
- @store = store
11
- @options = options
63
+ @classes = nil
64
+ @files = nil
65
+ @methods = nil
66
+ @modsort = nil
67
+ end
12
68
 
13
- $stderr.puts("rdoc-markdown initialized")
69
+ def generate
70
+ setup
71
+
72
+ debug("Create directory #{@output_dir}")
73
+
74
+ output_dir.mkpath
75
+
76
+ debug("Generate documentation in #{@output_dir}")
77
+
78
+ emit_classfiles
79
+ end
80
+
81
+ private
82
+
83
+ attr_reader :options
84
+ attr_reader :output_dir
85
+
86
+ def debug(str = nil)
87
+ if $DEBUG_RDOC
88
+ puts "[rdoc-markdown] #{str}" if str
89
+ yield if block_given?
14
90
  end
91
+ end
92
+
93
+ def emit_classfiles
94
+ @classes.each do |klass|
95
+ klass_methods = []
96
+ instance_methods = []
97
+
98
+ klass.method_list.each do |method|
99
+ next if 'private' == method.visibility.to_s
100
+ if method.type == 'class'
101
+ klass_methods << method
102
+ else
103
+ instance_methods << method
104
+ end
105
+ end
15
106
 
16
- def generate
17
- $stderr.puts("rdoc-markdown #generate called")
18
- binding.irb
107
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'classfile.md.erb'))
108
+
109
+ out_file = Pathname.new("#{output_dir}/#{klass.full_name}.md")
110
+ out_file.dirname.mkpath
111
+
112
+ File.open(out_file, 'wb') do |f|
113
+ f.write template.result binding
114
+ end
19
115
  end
20
- end
116
+ end
117
+
118
+ def setup
119
+ return if instance_variable_defined?(:@output_dir)
120
+
121
+ @output_dir = Pathname.new(@options.op_dir).expand_path(@base_dir)
122
+
123
+ return unless @store
124
+
125
+ @classes = @store.all_classes_and_modules.sort
126
+ @files = @store.all_files.sort
127
+ @methods = @classes.map(&:method_list).flatten.sort
128
+ @modsort = get_sorted_module_list @classes
129
+ end
130
+
131
+ ##
132
+ # Return a list of the documented modules sorted by salience first, then
133
+ # by name.
134
+
135
+ def get_sorted_module_list classes
136
+ classes.select do |klass|
137
+ klass.display?
138
+ end.sort
139
+ end
140
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rdoc
4
4
  module Markdown
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -0,0 +1,26 @@
1
+ # <%= klass.name %>
2
+ ## <% if klass.type == 'class' %><%= klass.type.capitalize %>[<%= klass.full_name %>](<%= klass.path %>)<% if klass.superclass %> inherits from <% end %><% unless String === klass.superclass %> [<%= klass.superclass.name %>](<%= klass.superclass.path %>) <% else %> <%= klass.superclass %> <% end %> <% else %> <%= klass.type.capitalize %> [<%= klass.name %>](<%= klass.path %>) <% end %>
3
+ <% if klass.description && !klass.description.empty? %><%= klass.description %><% end %>
4
+ <% unless klass.constants.empty? %><!-- Constants -->
5
+ ### Constants
6
+ <% klass.constants.sort_by { |x| x.name }.each do |const| %> <%= const.name %> <% end %>
7
+
8
+ <% end %>
9
+ <% unless klass.attributes.empty? %><!-- Attributes -->
10
+ ### Attributes
11
+ <% klass.attributes.sort_by { |x| x.name }.each do |attr| %><%= attr.name %>
12
+ <%= attr.rw %>
13
+ <%= attr.description %>
14
+
15
+ <% end %><% end %>
16
+ <% unless klass_methods.empty? %>
17
+ <!-- Class Methods -->
18
+ ### Public Class Methods
19
+ <% klass_methods.each do |method| %>[<%= method.name %><%= method.params %>](<%= method.aref %>)
20
+ <%= method.description %><% end %>
21
+
22
+ <% end %>
23
+ <% unless instance_methods.empty? %><!-- Instance Methods -->
24
+ ### Public Instance Methods
25
+ <% instance_methods.each do |method| %>[<%= method.name %><%= method.params %>](<%= method.aref %>)
26
+ <%= method.description %><% end %><% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-01 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -24,6 +24,90 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: erb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: standard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdiscount
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
27
111
  description: rdoc generator that produces markdown files
28
112
  email:
29
113
  - github@skatkov.com
@@ -32,21 +116,26 @@ extensions: []
32
116
  extra_rdoc_files: []
33
117
  files:
34
118
  - ".DS_Store"
119
+ - ".editorconfig"
35
120
  - ".standard.yml"
36
121
  - CODE_OF_CONDUCT.md
37
122
  - Gemfile
123
+ - Gemfile.lock
38
124
  - README.md
125
+ - Rakefile
126
+ - docs/example.rb
39
127
  - lib/.DS_Store
40
128
  - lib/markdown.rb
41
129
  - lib/rdoc/.DS_Store
42
130
  - lib/rdoc/discover.rb
43
131
  - lib/rdoc/generator/markdown.rb
44
132
  - lib/rdoc/markdown/version.rb
133
+ - lib/templates/classfile.md.erb
45
134
  - sig/rdoc/markdown.rbs
46
- homepage: https://github.com/skatkov/rdoc-markdown
135
+ homepage: https://poshtui.com
47
136
  licenses: []
48
137
  metadata:
49
- homepage_uri: https://github.com/skatkov/rdoc-markdown
138
+ homepage_uri: https://poshtui.com
50
139
  source_code_uri: https://github.com/skatkov/rdoc-markdown
51
140
  changelog_uri: https://github.com/skatkov/rdoc-markdown
52
141
  post_install_message: