yard-readme 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8fcf73f1ebef0ac81488b0ee0a04eba51bcc228e9ba8a6e414b444bc19a6335
4
- data.tar.gz: fe947ee1fc8c5fe274234e05feec1cf99238dbf20940542684ed3287289d4167
3
+ metadata.gz: 9c94f2e542f87b5beedce3e89f2d4797cdbcd3e3d80c84189da416e6ba54acbc
4
+ data.tar.gz: f6957e18616ccda27a169b201e6e4283c606440e01a805952f093ff02ffbaf57
5
5
  SHA512:
6
- metadata.gz: 4322e30867670192be390128fb6521de5985a70a156f9279d4419271be01e702a6e772365465bf3cf4746c7bbfbe567e410133f1ac5c4eb25c706a62ae9dbce6
7
- data.tar.gz: 18eeae3284d48faf9195c54162a1468602f55daaf07dffb2f2a6593d7a1f75034800c5bdc0e82bae46ebd836b2e4c21a7bfa4d1aa9e952a7a8fc065833eef6d4
6
+ metadata.gz: a7fa39d5a01d4cda411559832f607a20e0760bcc36279716c57b3af1c909c6b0a013d8ee6f41529a5f1acfca9cc34e0eea8ac7abfe2c3f6cabf1e0498dfb3c0a
7
+ data.tar.gz: f17ced1a3ccbc7b6106b7031cb9b9c6ed5f5ee6b5dc652482b65747f5d36462b924ad55bab922bcfdbf4d737ba7bb017841127b54e820a1ec3ae5841cfa01efb
data/CHANGELOG.md CHANGED
@@ -1,8 +1,39 @@
1
- ## [Unreleased]
1
+ ## [0.4.0] - 2025-05-03
2
+
3
+ ### Breaking Changes
4
+ - Changed module namespace from `YARDReadme` to `YARD::Readme` for better integration with YARD's namespace
5
+ - Moved files from `lib/yard-readme/` to `lib/yard/readme/` to match the new namespace structure
6
+ - Increased minimum required Ruby version from 2.4.0 to 3.0.0
7
+
8
+ ### Features
9
+ - Improved documentation with comprehensive explanations of how custom readme tags work
10
+ - Added example for `YARD::Readme::DocstringParser.readme_tag_names` to demonstrate usage
11
+ - Enhanced docstring comments with detailed API documentation
12
+ - Updated YARD plugin to better integrate with readme_yard 0.3.0+
13
+
14
+ ### Documentation Updates
15
+ - Restructured README with clear sections explaining the plugin's functionality
16
+ - Added detailed documentation for each component of the plugin:
17
+ - Custom Readme Tag Support
18
+ - Tag Processing functionality
19
+ - Tag Method descriptions
20
+ - Readme Text Processing explanations
21
+
22
+ ### Dependencies
23
+ - Updated YARD dependency from `~> 0.9.26` to `~> 0.9` to support newer versions
24
+ - Removed specific readme_yard development dependency, now integrates with any compatible version
25
+
26
+ ### Internal Changes
27
+ - Removed custom .yardopts file as it's now using the default configuration from readme_yard gem
28
+ - Added comprehensive RDoc-style documentation to all classes and methods
29
+
30
+ ## [0.3.0] - 2021-08-07
31
+
32
+ - Rename newly added methods be373f150e865b933a58a950e6a5c654395e17c4
2
33
 
3
34
  ## [0.2.0] - 2021-08-07
4
35
 
5
- - Be able to supprot new readme tag args in readme_yard without updating this gem b76ad2459168e4361ab38912e6faa7e36f249cec
36
+ - Be able to support new readme tag args in readme_yard without updating this gem b76ad2459168e4361ab38912e6faa7e36f249cec
6
37
 
7
38
  ## [0.1.2] - 2021-08-07
8
39
 
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in yard-readme.gemspec
6
6
  gemspec
7
+
8
+ gem 'readme_yard', '>= 0.3', path: '../readme_yard'
data/Gemfile.lock CHANGED
@@ -1,45 +1,69 @@
1
+ PATH
2
+ remote: ../readme_yard
3
+ specs:
4
+ readme_yard (0.3.0)
5
+ irb
6
+ tty-markdown (~> 0.7)
7
+ yard (~> 0.9)
8
+ yard-readme (~> 0.4)
9
+
1
10
  PATH
2
11
  remote: .
3
12
  specs:
4
- yard-readme (0.2.0)
5
- yard (~> 0.9.26)
13
+ yard-readme (0.4.0)
14
+ yard (~> 0.9)
6
15
 
7
16
  GEM
8
17
  remote: https://rubygems.org/
9
18
  specs:
10
- kramdown (2.3.1)
11
- rexml
19
+ date (3.4.1)
20
+ io-console (0.8.0)
21
+ irb (1.15.2)
22
+ pp (>= 0.6.0)
23
+ rdoc (>= 4.0.0)
24
+ reline (>= 0.4.2)
25
+ kramdown (2.5.1)
26
+ rexml (>= 3.3.9)
12
27
  pastel (0.8.0)
13
28
  tty-color (~> 0.5)
14
- readme_yard (0.1.2)
15
- tty-markdown (~> 0.7)
16
- yard-readme (~> 0.1)
17
- rexml (3.2.5)
18
- rouge (3.26.0)
29
+ pp (0.6.2)
30
+ prettyprint
31
+ prettyprint (0.2.0)
32
+ psych (5.2.4)
33
+ date
34
+ stringio
35
+ rdoc (6.13.1)
36
+ psych (>= 4.0.0)
37
+ reline (0.6.1)
38
+ io-console (~> 0.5)
39
+ rexml (3.4.1)
40
+ rouge (4.5.2)
41
+ stringio (3.1.7)
19
42
  strings (0.2.1)
20
43
  strings-ansi (~> 0.2)
21
44
  unicode-display_width (>= 1.5, < 3.0)
22
45
  unicode_utils (~> 1.4)
23
46
  strings-ansi (0.2.0)
24
47
  tty-color (0.6.0)
25
- tty-markdown (0.7.0)
48
+ tty-markdown (0.7.2)
26
49
  kramdown (>= 1.16.2, < 3.0)
27
50
  pastel (~> 0.8)
28
- rouge (~> 3.14)
51
+ rouge (>= 3.14, < 5.0)
29
52
  strings (~> 0.2.0)
30
53
  tty-color (~> 0.5)
31
54
  tty-screen (~> 0.8)
32
- tty-screen (0.8.1)
33
- unicode-display_width (2.0.0)
55
+ tty-screen (0.8.2)
56
+ unicode-display_width (2.6.0)
34
57
  unicode_utils (1.4.0)
35
- yard (0.9.26)
58
+ yard (0.9.37)
36
59
 
37
60
  PLATFORMS
38
- arm64-darwin-20
61
+ arm64-darwin-24
39
62
 
40
63
  DEPENDENCIES
41
- readme_yard (~> 0.1)
64
+ irb
65
+ readme_yard (>= 0.3)!
42
66
  yard-readme!
43
67
 
44
68
  BUNDLED WITH
45
- 2.2.24
69
+ 2.6.8
data/README.md CHANGED
@@ -12,11 +12,63 @@ comments in the source code to signal the README dependency
12
12
  without pushing the generated YARD documentation into a
13
13
  separate "readme" section.
14
14
 
15
- That said, I welcome a PR that adds the default behavior as an option, as I think it could be preferable for some use cases. Ideally, I or someone would open a YARD PR to make leaving
16
- the tag text an option when registering a tag. Especially
17
- since this plugin's current behavior of replacing the
18
- `YARD::DocstringParser` could potentially conflict with
19
- other YARD plugins and is also more vulnerable to change.
15
+
16
+ This plugin replaces YARD's default docstring parser with a custom one that handles @readme tags differently. This custom DocstringParser extends YARD's default parser to provide
17
+ special handling for @readme tags. The main functionality includes:
18
+
19
+ 1. Preserving the text content of @readme tags in the docstring
20
+ (instead of moving it to a separate "readme" section)
21
+ 2. Supporting nested @readme tags with custom names (like @readme comment)
22
+ 3. Properly handling empty/blank @readme tags
23
+
24
+
25
+ ## Custom Readme Tag Support
26
+
27
+ The yard-readme plugin includes support for custom readme tags as used by readme_yard. Custom readme tag names that should be stripped from the docstring
28
+ but preserved in the tag's text. This is used to support the nested tag
29
+ feature of readme_yard, where tags like `@readme comment`, `@readme source`,
30
+ and `@readme object` control what content gets embedded in the README.
31
+
32
+ By setting this attribute with an array of tag names (without the "@readme" prefix),
33
+ the parser will recognize these as special readme tags and handle them appropriately.
34
+
35
+
36
+ ```ruby
37
+ YARD::Readme::DocstringParser.readme_tag_names = ["comment", "source", "object"]
38
+ ```
39
+
40
+
41
+ ## Tag Processing
42
+
43
+ The plugin provides custom handling for @readme tags: Custom tag factory that overrides the default YARD tag factory
44
+ to provide special handling for @readme tags. Specifically,
45
+ it ensures that blank or empty @readme tags are properly processed.
46
+
47
+
48
+ ### Tag Methods
49
+
50
+ The TagFactory includes specialized methods for handling readme tags:
51
+
52
+ - This method ensures that @readme tags without any text are properly
53
+ handled, rather than being processed by the default YARD parser
54
+ which expects title and text for tags defined with :with_title_and_text.
55
+
56
+ - Checks if a tag is a blank @readme tag (no content).
57
+ This helper method is used to determine whether special
58
+ handling is needed for a given tag.
59
+
60
+
61
+ ## Readme Text Processing
62
+
63
+ The DocstringParser includes specialized methods for processing readme text:
64
+
65
+ - Determines whether a tag's text should be processed as readme text.
66
+ Only non-empty @readme tags are processed.
67
+
68
+ - Strips the @readme text of any readme-specific tag names
69
+ (as defined in readme_tag_names) and adds appropriate spacing.
70
+
71
+
20
72
 
21
73
  ## Contributing
22
74
 
data/README_YARD.md CHANGED
@@ -1,8 +1,33 @@
1
1
  # yard-readme
2
2
 
3
- {@readme YARDReadme}
3
+ {@readme YARD::Readme}
4
+
5
+ This plugin replaces YARD's default docstring parser with a custom one that handles @readme tags differently. {@readme YARD::Readme::DocstringParser}
6
+
7
+ ## Custom Readme Tag Support
8
+
9
+ The yard-readme plugin includes support for custom readme tags as used by readme_yard. {@readme YARD::Readme::DocstringParser.readme_tag_names}
10
+
11
+ {@example YARD::Readme::DocstringParser.readme_tag_names}
12
+
13
+ ## Tag Processing
14
+
15
+ The plugin provides custom handling for @readme tags: {@readme YARD::Readme::TagFactory}
16
+
17
+ ### Tag Methods
18
+
19
+ The TagFactory includes specialized methods for handling readme tags:
20
+
21
+ - {@readme YARD::Readme::TagFactory#parse_tag_with_title_and_text}
22
+ - {@readme YARD::Readme::TagFactory#blank_readme_tag?}
23
+
24
+ ## Readme Text Processing
25
+
26
+ The DocstringParser includes specialized methods for processing readme text:
27
+
28
+ - {@readme YARD::Readme::DocstringParser#parse_readme_text?}
29
+ - {@readme YARD::Readme::DocstringParser#parse_readme_text}
4
30
 
5
- That said, I welcome a PR that adds the default behavior as an option, as I think it could be preferable for some use cases. {@readme YARDReadme::DocstringParser}
6
31
 
7
32
  ## Contributing
8
33
 
@@ -0,0 +1,134 @@
1
+ module YARD
2
+ module Readme
3
+ #
4
+ # @readme
5
+ # This custom DocstringParser extends YARD's default parser to provide
6
+ # special handling for @readme tags. The main functionality includes:
7
+ #
8
+ # 1. Preserving the text content of @readme tags in the docstring
9
+ # (instead of moving it to a separate "readme" section)
10
+ # 2. Supporting nested @readme tags with custom names (like @readme comment)
11
+ # 3. Properly handling empty/blank @readme tags
12
+ #
13
+ # This implementation allows source code comments to signal README dependencies
14
+ # without altering how the YARD documentation is organized and displayed.
15
+ #
16
+ class DocstringParser < YARD::Docstring.default_parser
17
+ class << self
18
+ # @readme
19
+ # Custom readme tag names that should be stripped from the docstring
20
+ # but preserved in the tag's text. This is used to support the nested tag
21
+ # feature of readme_yard, where tags like `@readme comment`, `@readme source`,
22
+ # and `@readme object` control what content gets embedded in the README.
23
+ #
24
+ # By setting this attribute with an array of tag names (without the "@readme" prefix),
25
+ # the parser will recognize these as special readme tags and handle them appropriately.
26
+ #
27
+ # @example
28
+ # YARD::Readme::DocstringParser.readme_tag_names = ["comment", "source", "object"]
29
+ #
30
+ attr_accessor :readme_tag_names
31
+
32
+ def readme_tag_names_regex
33
+ @readme_tag_names_regex ||= /\A(#{readme_tag_names.join("|")})/
34
+ end
35
+
36
+ def readme_tag_names_regex?
37
+ readme_tag_names && !readme_tag_names.empty?
38
+ end
39
+
40
+ def strip_readme_tag_arg(text)
41
+ return text unless readme_tag_names_regex?
42
+
43
+ text.sub(readme_tag_names_regex, "")
44
+ end
45
+ end
46
+
47
+ def parse_content(content)
48
+ content = content.split(/\r?\n/) if content.is_a?(String)
49
+ return '' if !content || content.empty?
50
+ docstring = String.new("")
51
+
52
+ indent = content.first[/^\s*/].length
53
+ last_indent = 0
54
+ orig_indent = 0
55
+ directive = false
56
+ last_line = ""
57
+ tag_name = nil
58
+ tag_buf = []
59
+
60
+ (content + ['']).each_with_index do |line, index|
61
+ indent = line[/^\s*/].length
62
+ empty = (line =~ /^\s*$/ ? true : false)
63
+ done = content.size == index
64
+
65
+ if tag_name && (((indent < orig_indent && !empty) || done ||
66
+ (indent == 0 && !empty)) || (indent <= last_indent && line =~ META_MATCH))
67
+ buf = tag_buf.join("\n")
68
+ if directive || tag_is_directive?(tag_name)
69
+ directive = create_directive(tag_name, buf)
70
+ if directive
71
+ docstring << parse_content(directive.expanded_text).chomp
72
+ end
73
+ else
74
+ readme_text = parse_readme_text(buf) if parse_readme_text?(tag_name, buf)
75
+ docstring << readme_text if readme_text
76
+ create_tag(tag_name, buf)
77
+ end
78
+ tag_name = nil
79
+ tag_buf = []
80
+ directive = false
81
+ orig_indent = 0
82
+ end
83
+
84
+ # Found a meta tag
85
+ if line =~ META_MATCH
86
+ directive = $1
87
+ tag_name = $2
88
+ tag_buf = [($3 || '')]
89
+ elsif tag_name && indent >= orig_indent && !empty
90
+ orig_indent = indent if orig_indent == 0
91
+ # Extra data added to the tag on the next line
92
+ last_empty = last_line =~ /^[ \t]*$/ ? true : false
93
+
94
+ tag_buf << '' if last_empty
95
+ tag_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
96
+ elsif !tag_name
97
+ # Regular docstring text
98
+ docstring << line
99
+ docstring << "\n"
100
+ end
101
+
102
+ last_indent = indent
103
+ last_line = line
104
+ end
105
+
106
+ docstring
107
+ end
108
+
109
+ # @readme
110
+ # Strips the @readme text of any readme-specific tag names
111
+ # (as defined in readme_tag_names) and adds appropriate spacing.
112
+ #
113
+ # @param [String] text the raw text from the @readme tag
114
+ # @return [String, nil] the processed text or nil if no processing was done
115
+ #
116
+ def parse_readme_text(text)
117
+ readme_text = self.class.strip_readme_tag_arg(text)
118
+ readme_text << "\n\n" if readme_text
119
+ end
120
+
121
+ # @readme
122
+ # Determines whether a tag's text should be processed as readme text.
123
+ # Only non-empty @readme tags are processed.
124
+ #
125
+ # @param [String] tag_name the name of the tag
126
+ # @param [String] buf the tag's text buffer
127
+ # @return [Boolean] true if the tag should be processed as readme text
128
+ #
129
+ def parse_readme_text?(tag_name, buf)
130
+ tag_name == 'readme' && !buf.empty?
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,42 @@
1
+ module YARD
2
+ module Readme
3
+ # @readme
4
+ # Custom tag factory that overrides the default YARD tag factory
5
+ # to provide special handling for @readme tags. Specifically,
6
+ # it ensures that blank or empty @readme tags are properly processed.
7
+ #
8
+ class TagFactory < YARD::Tags::Library.default_factory.class
9
+ #
10
+ # Overrides the default tag parsing behavior to handle blank @readme tags.
11
+ #
12
+ # @param [String] tag_name the name of the tag
13
+ # @param [String] text the tag text
14
+ # @return [YARD::Tags::Tag] the parsed tag
15
+ # @see https://github.com/lsegal/yard/blob/359006641260eef1fe6d28f5c43c7c98d40f257d/lib/yard/tags/default_factory.rb#L70
16
+ #
17
+ # @readme
18
+ # This method ensures that @readme tags without any text are properly
19
+ # handled, rather than being processed by the default YARD parser
20
+ # which expects title and text for tags defined with :with_title_and_text.
21
+ #
22
+ def parse_tag_with_title_and_text(tag_name, text)
23
+ return YARD::Tags::Tag.new(tag_name, text) if blank_readme_tag?(tag_name, text)
24
+
25
+ super
26
+ end
27
+
28
+ # @readme
29
+ # Checks if a tag is a blank @readme tag (no content).
30
+ # This helper method is used to determine whether special
31
+ # handling is needed for a given tag.
32
+ #
33
+ # @param [String] tag_name the name of the tag
34
+ # @param [String] text the tag text
35
+ # @return [Boolean] true if the tag is a blank readme tag
36
+ #
37
+ def blank_readme_tag?(tag_name, text)
38
+ tag_name == "readme" && text.nil? || text.empty?
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YARD
4
+ module Readme
5
+ VERSION = "0.4.0"
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yard'
4
+ require_relative "readme/version"
5
+ require_relative "readme/docstring_parser"
6
+ require_relative "readme/tag_factory"
7
+
8
+ module YARD
9
+ #
10
+ # @readme
11
+ # A [YARD](https://yardoc.org) plugin used by
12
+ # [readme_yard](https://github.com/mattruzicka/readme_yard).
13
+ # It adds a `@readme` tag to YARD.
14
+ #
15
+ # It also replaces the default docstring parser so that only
16
+ # `@readme` tags and not their text values are stripped from
17
+ # the generated documentation. I prefer this over the default
18
+ # YARD behavior for the `@readme` tag because it allows the
19
+ # comments in the source code to signal the README dependency
20
+ # without pushing the generated YARD documentation into a
21
+ # separate "readme" section.
22
+ #
23
+ module Readme
24
+ #
25
+ # @see https://www.rubydoc.info/gems/yard/0.9.13/YARD/DocstringParser
26
+ #
27
+ YARD::Docstring.default_parser = YARD::Readme::DocstringParser
28
+
29
+ #
30
+ # @see https://www.rubydoc.info/gems/yard/file/docs/TagsArch.md
31
+ #
32
+ YARD::Tags::Library.default_factory = YARD::Readme::TagFactory
33
+
34
+ YARD::Tags::Library.define_tag('README', :readme, :with_title_and_text)
35
+ end
36
+ end
data/lib/yard-readme.rb CHANGED
@@ -1,34 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yard'
4
- require_relative 'yard-readme/version'
5
- require_relative 'yard-readme/docstring_parser'
6
- require_relative 'yard-readme/tag_factory'
7
-
8
- #
9
- # @readme
10
- # A [YARD](https://yardoc.org) plugin used by
11
- # [readme_yard](https://github.com/mattruzicka/readme_yard).
12
- # It adds a `@readme` tag to YARD.
13
- #
14
- # It also replaces the default docstring parser so that only
15
- # `@readme` tags and not their text values are stripped from
16
- # the generated documentation. I prefer this over the default
17
- # YARD behavior for the `@readme` tag because it allows the
18
- # comments in the source code to signal the README dependency
19
- # without pushing the generated YARD documentation into a
20
- # separate "readme" section.
21
- #
22
- module YARDReadme; end
23
-
24
- #
25
- # @see https://www.rubydoc.info/gems/yard/0.9.13/YARD/DocstringParser
26
- #
27
- YARD::Docstring.default_parser = YARDReadme::DocstringParser
28
-
29
- #
30
- # @see https://www.rubydoc.info/gems/yard/file/docs/TagsArch.md
31
- #
32
- YARD::Tags::Library.default_factory = YARDReadme::TagFactory
33
-
34
- YARD::Tags::Library.define_tag('README', :readme, :with_title_and_text)
4
+ require_relative 'yard/readme'
data/yard-readme.gemspec CHANGED
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/yard-readme/version"
3
+ require_relative 'lib/yard/readme/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "yard-readme"
7
- spec.version = YARDReadme::VERSION
7
+ spec.version = YARD::Readme::VERSION
8
8
  spec.authors = ["Matt Ruzicka"]
9
9
  spec.license = "MIT"
10
10
 
11
11
  spec.summary = "Enhance your README with YARD"
12
12
  spec.description = "Generate your README using comments in your code"
13
13
  spec.homepage = 'https://github.com/mattruzicka/yard-readme'
14
- spec.required_ruby_version = ">= 2.4.0"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = spec.homepage
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  # Uncomment to register a new dependency of your gem
30
- spec.add_dependency "yard", "~> 0.9.26"
30
+ spec.add_dependency "yard", "~> 0.9"
31
31
 
32
- spec.add_development_dependency 'readme_yard', "~> 0.1"
32
+ spec.add_development_dependency 'irb'
33
33
 
34
34
  # For more information and examples about making a new gem, checkout our
35
35
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-readme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ruzicka
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-08-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: yard
@@ -16,37 +15,35 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 0.9.26
18
+ version: '0.9'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 0.9.26
25
+ version: '0.9'
27
26
  - !ruby/object:Gem::Dependency
28
- name: readme_yard
27
+ name: irb
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '0.1'
32
+ version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '0.1'
39
+ version: '0'
41
40
  description: Generate your README using comments in your code
42
- email:
43
41
  executables: []
44
42
  extensions: []
45
43
  extra_rdoc_files: []
46
44
  files:
47
45
  - ".gitignore"
48
46
  - ".rubocop.yml"
49
- - ".yardopts"
50
47
  - CHANGELOG.md
51
48
  - Gemfile
52
49
  - Gemfile.lock
@@ -55,9 +52,10 @@ files:
55
52
  - bin/console
56
53
  - bin/setup
57
54
  - lib/yard-readme.rb
58
- - lib/yard-readme/docstring_parser.rb
59
- - lib/yard-readme/tag_factory.rb
60
- - lib/yard-readme/version.rb
55
+ - lib/yard/readme.rb
56
+ - lib/yard/readme/docstring_parser.rb
57
+ - lib/yard/readme/tag_factory.rb
58
+ - lib/yard/readme/version.rb
61
59
  - yard-readme.gemspec
62
60
  homepage: https://github.com/mattruzicka/yard-readme
63
61
  licenses:
@@ -66,7 +64,6 @@ metadata:
66
64
  homepage_uri: https://github.com/mattruzicka/yard-readme
67
65
  source_code_uri: https://github.com/mattruzicka/yard-readme
68
66
  changelog_uri: https://github.com/mattruzicka/yard-readme/blob/master/CHANGELOG.md
69
- post_install_message:
70
67
  rdoc_options: []
71
68
  require_paths:
72
69
  - lib
@@ -74,15 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
71
  requirements:
75
72
  - - ">="
76
73
  - !ruby/object:Gem::Version
77
- version: 2.4.0
74
+ version: 3.0.0
78
75
  required_rubygems_version: !ruby/object:Gem::Requirement
79
76
  requirements:
80
77
  - - ">="
81
78
  - !ruby/object:Gem::Version
82
79
  version: '0'
83
80
  requirements: []
84
- rubygems_version: 3.2.3
85
- signing_key:
81
+ rubygems_version: 3.6.8
86
82
  specification_version: 4
87
83
  summary: Enhance your README with YARD
88
84
  test_files: []
data/.yardopts DELETED
@@ -1,3 +0,0 @@
1
- -e lib/yard-readme.rb
2
- --markup markdown
3
- lib/**/*.rb
@@ -1,102 +0,0 @@
1
- module YARDReadme
2
- #
3
- # @readme
4
- # Ideally, I or someone would open a YARD PR to make leaving
5
- # the tag text an option when registering a tag. Especially
6
- # since this plugin's current behavior of replacing the
7
- # `YARD::DocstringParser` could potentially conflict with
8
- # other YARD plugins and is also more vulnerable to change.
9
- #
10
- # Doing so would make this custom parser obsolete.
11
- #
12
- class DocstringParser < YARD::Docstring.default_parser
13
- class << self
14
- attr_accessor :readme_tag_args
15
-
16
- def readme_tag_args_regex
17
- @readme_tag_args_regex ||= /\A(#{readme_tag_args.join("|")})/
18
- end
19
-
20
- def readme_tag_args_regex?
21
- readme_tag_args && !readme_tag_args.empty?
22
- end
23
-
24
- def strip_readme_tag_arg(text)
25
- return text unless readme_tag_args_regex?
26
-
27
- text.sub(readme_tag_args_regex, "")
28
- end
29
- end
30
-
31
- def parse_content(content)
32
- content = content.split(/\r?\n/) if content.is_a?(String)
33
- return '' if !content || content.empty?
34
- docstring = String.new("")
35
-
36
- indent = content.first[/^\s*/].length
37
- last_indent = 0
38
- orig_indent = 0
39
- directive = false
40
- last_line = ""
41
- tag_name = nil
42
- tag_buf = []
43
-
44
- (content + ['']).each_with_index do |line, index|
45
- indent = line[/^\s*/].length
46
- empty = (line =~ /^\s*$/ ? true : false)
47
- done = content.size == index
48
-
49
- if tag_name && (((indent < orig_indent && !empty) || done ||
50
- (indent == 0 && !empty)) || (indent <= last_indent && line =~ META_MATCH))
51
- buf = tag_buf.join("\n")
52
- if directive || tag_is_directive?(tag_name)
53
- directive = create_directive(tag_name, buf)
54
- if directive
55
- docstring << parse_content(directive.expanded_text).chomp
56
- end
57
- else
58
- readme_text = parse_readme_text(buf) if parse_readme_text?(tag_name, buf)
59
- docstring << readme_text if readme_text
60
- create_tag(tag_name, buf)
61
- end
62
- tag_name = nil
63
- tag_buf = []
64
- directive = false
65
- orig_indent = 0
66
- end
67
-
68
- # Found a meta tag
69
- if line =~ META_MATCH
70
- directive = $1
71
- tag_name = $2
72
- tag_buf = [($3 || '')]
73
- elsif tag_name && indent >= orig_indent && !empty
74
- orig_indent = indent if orig_indent == 0
75
- # Extra data added to the tag on the next line
76
- last_empty = last_line =~ /^[ \t]*$/ ? true : false
77
-
78
- tag_buf << '' if last_empty
79
- tag_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
80
- elsif !tag_name
81
- # Regular docstring text
82
- docstring << line
83
- docstring << "\n"
84
- end
85
-
86
- last_indent = indent
87
- last_line = line
88
- end
89
-
90
- docstring
91
- end
92
-
93
- def parse_readme_text(text)
94
- readme_text = self.class.strip_readme_tag_arg(text)
95
- readme_text << "\n\n" if readme_text
96
- end
97
-
98
- def parse_readme_text?(tag_name, buf)
99
- tag_name == 'readme' && !buf.empty?
100
- end
101
- end
102
- end
@@ -1,16 +0,0 @@
1
- module YARDReadme
2
- class TagFactory < YARD::Tags::Library.default_factory.class
3
- #
4
- # @see https://github.com/lsegal/yard/blob/359006641260eef1fe6d28f5c43c7c98d40f257d/lib/yard/tags/default_factory.rb#L70
5
- #
6
- def parse_tag_with_title_and_text(tag_name, text)
7
- return YARD::Tags::Tag.new(tag_name, text) if blank_readme_tag?(tag_name, text)
8
-
9
- super
10
- end
11
-
12
- def blank_readme_tag?(tag_name, text)
13
- tag_name == "readme" && text.nil? || text.empty?
14
- end
15
- end
16
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module YARDReadme
4
- VERSION = "0.2.0"
5
- end