yard-readme 0.3.0 → 0.5.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: dcd61abdc1876be598a2d532300f924ad55a57bfd1621c547a3af4ae58e66878
4
- data.tar.gz: 86efaa1311664e611826262de6d8b0a959069033e1eee9f95f7e4b1cbd3bd4a6
3
+ metadata.gz: 676cae1299410a644a61764533557124b7cd287abbe81238126fd96366c76fbc
4
+ data.tar.gz: 173694a562cd4e73025fcc29a703d04781d29e157e7f42c675d55c171a235f14
5
5
  SHA512:
6
- metadata.gz: c782d9c5accdc97a479ca316bb5c779fbaf0f48a0aa638bc9c9f732bc04b941206eb2fe7f82eab7131d463f5daafee32f43e16c8035935301fe61688a01342ad
7
- data.tar.gz: f80feffe36580aca84fc820e46bf44218992199da1e6c23a38791a37a560ffc7702246ad2ed55f655b54dd368730ffb4127ac801af6cf17a912d532d56dcd60f
6
+ metadata.gz: b3e2c9d544b52798c72a5be125217a2a534dc71ca0b9df3d1caaf6c681114f7c385f87971ebf80514399d66c946fc07863989968af876f1cfe32680cc1d8f4de
7
+ data.tar.gz: b74bdd141f0d7ffdc63f7827a76a48da6e6ca4382dde61c6594534970f6d14772f00e39856642a879ea19ece7980cd56050fc783bfb04a6256dd8468ccb4f6ae
data/.yardopts CHANGED
@@ -1,3 +1,2 @@
1
- -e lib/yard-readme.rb
1
+ --plugin readme
2
2
  --markup markdown
3
- lib/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,4 +1,34 @@
1
- ## [Unreleased]
1
+ ## [0.5.0] - 2025-05-04
2
+
3
+ - Extracted description into separate file `lib/yard/readme/description.rb`
4
+ - Updated documentation to use this centralized description in gemspec and README
5
+ - Updated tag examples from `@readme object` to `@readme code` to reflect readme_yard updates
6
+ - Updated README
7
+
8
+ ## [0.4.0] - 2025-05-03
9
+
10
+ ### Breaking Changes
11
+ - Changed module namespace from `YARDReadme` to `YARD::Readme` for better integration with YARD's namespace
12
+ - Moved files from `lib/yard-readme/` to `lib/yard/readme/` to match the new namespace structure
13
+ - Increased minimum required Ruby version from 2.4.0 to 3.0.0
14
+
15
+ ### Features
16
+ - Improved documentation with comprehensive explanations of how custom readme tags work
17
+ - Added example for `YARD::Readme::DocstringParser.readme_tag_names` to demonstrate usage
18
+ - Enhanced docstring comments with detailed API documentation
19
+ - Updated YARD plugin to better integrate with readme_yard 0.3.0+
20
+
21
+ ### Documentation Updates
22
+ - Restructured README with clear sections explaining the plugin's functionality
23
+ - Added detailed documentation for each component of the plugin:
24
+ - Custom Readme Tag Support
25
+ - Tag Processing functionality
26
+ - Tag Method descriptions
27
+ - Readme Text Processing explanations
28
+
29
+ ### Dependencies
30
+ - Updated YARD dependency from `~> 0.9.26` to `~> 0.9` to support newer versions
31
+ - Removed specific readme_yard development dependency, now integrates with any compatible version
2
32
 
3
33
  ## [0.3.0] - 2021-08-07
4
34
 
data/Gemfile CHANGED
@@ -4,3 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in yard-readme.gemspec
6
6
  gemspec
7
+
8
+ gem "debug"
9
+ gem 'readme_yard', '>= 0.3', path: '../readme_yard'
data/Gemfile.lock CHANGED
@@ -1,45 +1,71 @@
1
+ PATH
2
+ remote: ../readme_yard
3
+ specs:
4
+ readme_yard (0.3.0)
5
+ tty-markdown (~> 0.7)
6
+ yard (~> 0.9)
7
+ yard-readme (~> 0.4)
8
+
1
9
  PATH
2
10
  remote: .
3
11
  specs:
4
- yard-readme (0.2.0)
5
- yard (~> 0.9.26)
12
+ yard-readme (0.5.0)
6
13
 
7
14
  GEM
8
15
  remote: https://rubygems.org/
9
16
  specs:
10
- kramdown (2.3.1)
11
- rexml
17
+ date (3.4.1)
18
+ debug (1.10.0)
19
+ irb (~> 1.10)
20
+ reline (>= 0.3.8)
21
+ io-console (0.8.0)
22
+ irb (1.15.2)
23
+ pp (>= 0.6.0)
24
+ rdoc (>= 4.0.0)
25
+ reline (>= 0.4.2)
26
+ kramdown (2.5.1)
27
+ rexml (>= 3.3.9)
12
28
  pastel (0.8.0)
13
29
  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)
30
+ pp (0.6.2)
31
+ prettyprint
32
+ prettyprint (0.2.0)
33
+ psych (5.2.4)
34
+ date
35
+ stringio
36
+ rdoc (6.13.1)
37
+ psych (>= 4.0.0)
38
+ reline (0.6.1)
39
+ io-console (~> 0.5)
40
+ rexml (3.4.1)
41
+ rouge (4.5.2)
42
+ stringio (3.1.7)
19
43
  strings (0.2.1)
20
44
  strings-ansi (~> 0.2)
21
45
  unicode-display_width (>= 1.5, < 3.0)
22
46
  unicode_utils (~> 1.4)
23
47
  strings-ansi (0.2.0)
24
48
  tty-color (0.6.0)
25
- tty-markdown (0.7.0)
49
+ tty-markdown (0.7.2)
26
50
  kramdown (>= 1.16.2, < 3.0)
27
51
  pastel (~> 0.8)
28
- rouge (~> 3.14)
52
+ rouge (>= 3.14, < 5.0)
29
53
  strings (~> 0.2.0)
30
54
  tty-color (~> 0.5)
31
55
  tty-screen (~> 0.8)
32
- tty-screen (0.8.1)
33
- unicode-display_width (2.0.0)
56
+ tty-screen (0.8.2)
57
+ unicode-display_width (2.6.0)
34
58
  unicode_utils (1.4.0)
35
- yard (0.9.26)
59
+ yard (0.9.37)
36
60
 
37
61
  PLATFORMS
38
- arm64-darwin-20
62
+ arm64-darwin-24
39
63
 
40
64
  DEPENDENCIES
41
- readme_yard (~> 0.1)
65
+ debug
66
+ irb
67
+ readme_yard (>= 0.3)!
42
68
  yard-readme!
43
69
 
44
70
  BUNDLED WITH
45
- 2.2.24
71
+ 2.6.8
data/README.md CHANGED
@@ -1,22 +1,65 @@
1
1
  # yard-readme
2
2
 
3
- A [YARD](https://yardoc.org) plugin used by
4
- [readme_yard](https://github.com/mattruzicka/readme_yard).
5
- It adds a `@readme` tag to YARD.
6
-
7
- It also replaces the default docstring parser so that only
8
- `@readme` tags and not their text values are stripped from
9
- the generated documentation. I prefer this over the default
10
- YARD behavior for the `@readme` tag because it allows the
11
- comments in the source code to signal the README dependency
12
- without pushing the generated YARD documentation into a
13
- separate "readme" section.
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.
3
+ Built for the [readme_yard](https://github.com/mattruzicka/readme_yard) gem as:
4
+
5
+ A YARD plugin that introduces the @readme tag and powers the readme_yard gem, enabling developers to embed code comments directly into README sections. This eliminates redundancy and keeps documentation consistent across code and project READMEs.
6
+
7
+ 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
8
+ special handling for @readme tags. The main functionality includes:
9
+
10
+ 1. Preserving the text content of @readme tags in the docstring
11
+ (instead of moving it to a separate "readme" section)
12
+ 2. Supporting nested @readme tags with custom names (like @readme comment)
13
+ 3. Properly handling empty/blank @readme tags
14
+
15
+
16
+ ## Custom Readme Tag Support
17
+
18
+ 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
19
+ but preserved in the tag's text. This is used to support the nested tag
20
+ feature of readme_yard, where tags like `@readme comment`, `@readme code`,
21
+ and `@readme source` control what content gets embedded in the README.
22
+
23
+ By setting this attribute with an array of tag names (without the "@readme" prefix),
24
+ the parser will recognize these as special readme tags and handle them appropriately.
25
+
26
+
27
+ ```ruby
28
+ YARD::Readme::DocstringParser.readme_tag_names = ["comment", "code", "source"]
29
+ ```
30
+
31
+
32
+ ## Tag Processing
33
+
34
+ The plugin provides custom handling for @readme tags: Custom tag factory that overrides the default YARD tag factory
35
+ to provide special handling for @readme tags. Specifically,
36
+ it ensures that blank or empty @readme tags are properly processed.
37
+
38
+
39
+ ### Tag Methods
40
+
41
+ The TagFactory includes specialized methods for handling readme tags:
42
+
43
+ - This method ensures that @readme tags without any text are properly
44
+ handled, rather than being processed by the default YARD parser
45
+ which expects title and text for tags defined with :with_title_and_text.
46
+
47
+ - Checks if a tag is a blank @readme tag (no content).
48
+ This helper method is used to determine whether special
49
+ handling is needed for a given tag.
50
+
51
+
52
+ ## Readme Text Processing
53
+
54
+ The DocstringParser includes specialized methods for processing readme text:
55
+
56
+ - Determines whether a tag's text should be processed as readme text.
57
+ Only non-empty @readme tags are processed.
58
+
59
+ - Strips the @readme text of any readme-specific tag names
60
+ (as defined in readme_tag_names) and adds appropriate spacing.
61
+
62
+
20
63
 
21
64
  ## Contributing
22
65
 
data/README_YARD.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # yard-readme
2
2
 
3
- {@readme YARDReadme}
3
+ Built for the [readme_yard](https://github.com/mattruzicka/readme_yard) gem as:
4
+
5
+ {@readme YARD::Readme::DESCRIPTION}
6
+
7
+ This plugin replaces YARD's default docstring parser with a custom one that handles @readme tags differently. {@readme YARD::Readme::DocstringParser}
8
+
9
+ ## Custom Readme Tag Support
10
+
11
+ The yard-readme plugin includes support for custom readme tags as used by readme_yard. {@readme YARD::Readme::DocstringParser.readme_tag_names}
12
+
13
+ {@example YARD::Readme::DocstringParser.readme_tag_names}
14
+
15
+ ## Tag Processing
16
+
17
+ The plugin provides custom handling for @readme tags: {@readme YARD::Readme::TagFactory}
18
+
19
+ ### Tag Methods
20
+
21
+ The TagFactory includes specialized methods for handling readme tags:
22
+
23
+ - {@readme YARD::Readme::TagFactory#parse_tag_with_title_and_text}
24
+ - {@readme YARD::Readme::TagFactory#blank_readme_tag?}
25
+
26
+ ## Readme Text Processing
27
+
28
+ The DocstringParser includes specialized methods for processing readme text:
29
+
30
+ - {@readme YARD::Readme::DocstringParser#parse_readme_text?}
31
+ - {@readme YARD::Readme::DocstringParser#parse_readme_text}
4
32
 
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
33
 
7
34
  ## Contributing
8
35
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YARD
4
+ module Readme
5
+ #
6
+ # @readme String
7
+ #
8
+ DESCRIPTION = "A YARD plugin that introduces the @readme tag and powers the readme_yard gem, enabling developers to embed code comments directly into README sections. This eliminates redundancy and keeps documentation consistent across code and project READMEs."
9
+ end
10
+ end
11
+
12
+
@@ -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 code`,
22
+ # and `@readme source` 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", "code", "source"]
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.5.0"
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "readme/version"
4
+ require_relative "readme/description"
5
+ require_relative "readme/docstring_parser"
6
+ require_relative "readme/tag_factory"
7
+
8
+ module YARD
9
+ module Readme
10
+ #
11
+ # @see https://www.rubydoc.info/gems/yard/0.9.13/YARD/DocstringParser
12
+ #
13
+ YARD::Docstring.default_parser = YARD::Readme::DocstringParser
14
+
15
+ #
16
+ # @see https://www.rubydoc.info/gems/yard/file/docs/TagsArch.md
17
+ #
18
+ YARD::Tags::Library.default_factory = YARD::Readme::TagFactory
19
+
20
+ YARD::Tags::Library.define_tag('README', :readme, :with_title_and_text)
21
+ end
22
+ end
data/lib/yard-readme.rb CHANGED
@@ -1,34 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
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)
3
+ require_relative 'yard/readme'
data/yard-readme.gemspec CHANGED
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/yard-readme/version"
3
+ require_relative 'lib/yard/readme/version'
4
+ require_relative 'lib/yard/readme/description'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = "yard-readme"
7
- spec.version = YARDReadme::VERSION
8
+ spec.version = YARD::Readme::VERSION
8
9
  spec.authors = ["Matt Ruzicka"]
9
10
  spec.license = "MIT"
10
11
 
11
- spec.summary = "Enhance your README with YARD"
12
- spec.description = "Generate your README using comments in your code"
12
+ spec.summary = "YARD plugin for the readme_yard gem"
13
+ spec.description = YARD::Readme::DESCRIPTION
13
14
  spec.homepage = 'https://github.com/mattruzicka/yard-readme'
14
- spec.required_ruby_version = ">= 2.4.0"
15
+ spec.required_ruby_version = ">= 3.0.0"
15
16
 
16
17
  spec.metadata["homepage_uri"] = spec.homepage
17
18
  spec.metadata["source_code_uri"] = spec.homepage
@@ -27,9 +28,7 @@ Gem::Specification.new do |spec|
27
28
  spec.require_paths = ["lib"]
28
29
 
29
30
  # Uncomment to register a new dependency of your gem
30
- spec.add_dependency "yard", "~> 0.9.26"
31
-
32
- spec.add_development_dependency 'readme_yard', "~> 0.1"
31
+ spec.add_development_dependency 'irb'
33
32
 
34
33
  # For more information and examples about making a new gem, checkout our
35
34
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,45 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-readme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.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-08 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
- name: yard
13
+ name: irb
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 0.9.26
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.9.26
27
- - !ruby/object:Gem::Dependency
28
- name: readme_yard
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.1'
18
+ version: '0'
34
19
  type: :development
35
20
  prerelease: false
36
21
  version_requirements: !ruby/object:Gem::Requirement
37
22
  requirements:
38
- - - "~>"
23
+ - - ">="
39
24
  - !ruby/object:Gem::Version
40
- version: '0.1'
41
- description: Generate your README using comments in your code
42
- email:
25
+ version: '0'
26
+ description: A YARD plugin that introduces the @readme tag and powers the readme_yard
27
+ gem, enabling developers to embed code comments directly into README sections. This
28
+ eliminates redundancy and keeps documentation consistent across code and project
29
+ READMEs.
43
30
  executables: []
44
31
  extensions: []
45
32
  extra_rdoc_files: []
@@ -55,9 +42,11 @@ files:
55
42
  - bin/console
56
43
  - bin/setup
57
44
  - lib/yard-readme.rb
58
- - lib/yard-readme/docstring_parser.rb
59
- - lib/yard-readme/tag_factory.rb
60
- - lib/yard-readme/version.rb
45
+ - lib/yard/readme.rb
46
+ - lib/yard/readme/description.rb
47
+ - lib/yard/readme/docstring_parser.rb
48
+ - lib/yard/readme/tag_factory.rb
49
+ - lib/yard/readme/version.rb
61
50
  - yard-readme.gemspec
62
51
  homepage: https://github.com/mattruzicka/yard-readme
63
52
  licenses:
@@ -66,7 +55,6 @@ metadata:
66
55
  homepage_uri: https://github.com/mattruzicka/yard-readme
67
56
  source_code_uri: https://github.com/mattruzicka/yard-readme
68
57
  changelog_uri: https://github.com/mattruzicka/yard-readme/blob/master/CHANGELOG.md
69
- post_install_message:
70
58
  rdoc_options: []
71
59
  require_paths:
72
60
  - lib
@@ -74,15 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
62
  requirements:
75
63
  - - ">="
76
64
  - !ruby/object:Gem::Version
77
- version: 2.4.0
65
+ version: 3.0.0
78
66
  required_rubygems_version: !ruby/object:Gem::Requirement
79
67
  requirements:
80
68
  - - ">="
81
69
  - !ruby/object:Gem::Version
82
70
  version: '0'
83
71
  requirements: []
84
- rubygems_version: 3.2.3
85
- signing_key:
72
+ rubygems_version: 3.6.8
86
73
  specification_version: 4
87
- summary: Enhance your README with YARD
74
+ summary: YARD plugin for the readme_yard gem
88
75
  test_files: []
@@ -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_names
15
-
16
- def readme_tag_names_regex
17
- @readme_tag_names_regex ||= /\A(#{readme_tag_names.join("|")})/
18
- end
19
-
20
- def readme_tag_names_regex?
21
- readme_tag_names && !readme_tag_names.empty?
22
- end
23
-
24
- def strip_readme_tag_arg(text)
25
- return text unless readme_tag_names_regex?
26
-
27
- text.sub(readme_tag_names_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.3.0"
5
- end