yard-readme 0.1.0 → 0.3.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: d4ec34f12f41177c0652dcf498e833a03b2492e0faf1c487ee40b149bf41b2eb
4
- data.tar.gz: 362213c9dd24df82f3396dd81218fe623050d91eb7c59adaed04fbe3587d44b9
3
+ metadata.gz: dcd61abdc1876be598a2d532300f924ad55a57bfd1621c547a3af4ae58e66878
4
+ data.tar.gz: 86efaa1311664e611826262de6d8b0a959069033e1eee9f95f7e4b1cbd3bd4a6
5
5
  SHA512:
6
- metadata.gz: ecda196fad92caf901bbe43c0661dc961fc8abc39ee6aff954144167b6741e6ac5f6d4f6679fbf48a3cb849f64840ff7841039860225da57bc9e6f42a9e0a98c
7
- data.tar.gz: 854dbe3d3d9ae01097edc0681d4f267248bb9db5107c01f49a8238131316ceab9f622e11253e1addce0c6d60d67d81c5ddcb659ad4129165a25a7199565d9cca
6
+ metadata.gz: c782d9c5accdc97a479ca316bb5c779fbaf0f48a0aa638bc9c9f732bc04b941206eb2fe7f82eab7131d463f5daafee32f43e16c8035935301fe61688a01342ad
7
+ data.tar.gz: f80feffe36580aca84fc820e46bf44218992199da1e6c23a38791a37a560ffc7702246ad2ed55f655b54dd368730ffb4127ac801af6cf17a912d532d56dcd60f
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ .byebug_history
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.yardopts CHANGED
@@ -1,2 +1,3 @@
1
- --plugin readme
1
+ -e lib/yard-readme.rb
2
+ --markup markdown
2
3
  lib/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2021-08-07
4
+
5
+ - Rename newly added methods be373f150e865b933a58a950e6a5c654395e17c4
6
+
7
+ ## [0.2.0] - 2021-08-07
8
+
9
+ - Be able to support new readme tag args in readme_yard without updating this gem b76ad2459168e4361ab38912e6faa7e36f249cec
10
+
11
+ ## [0.1.2] - 2021-08-07
12
+
13
+ - Inherit from existing default to minimize conflict between plugins 69463cb2f580a1f5bcb734564eb51b32bf833250
14
+ - Avoid raising error when readme tag text is blank 294c9400de41d297c71212939b410e4ce821bc15
15
+ - Remove special readme tag names (README_YARD args) from docs when parsing docstring 983e1485b89888d390dc4879e7019fd7785dedda
16
+
17
+ ## [0.1.1] - 2021-07-31
18
+
19
+ - Use readme_yard to build README
20
+
3
21
  ## [0.1.0] - 2021-07-25
4
22
 
5
23
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,18 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yard-readme (0.1.0)
5
- yard
4
+ yard-readme (0.2.0)
5
+ yard (~> 0.9.26)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ kramdown (2.3.1)
11
+ rexml
12
+ pastel (0.8.0)
13
+ 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)
19
+ strings (0.2.1)
20
+ strings-ansi (~> 0.2)
21
+ unicode-display_width (>= 1.5, < 3.0)
22
+ unicode_utils (~> 1.4)
23
+ strings-ansi (0.2.0)
24
+ tty-color (0.6.0)
25
+ tty-markdown (0.7.0)
26
+ kramdown (>= 1.16.2, < 3.0)
27
+ pastel (~> 0.8)
28
+ rouge (~> 3.14)
29
+ strings (~> 0.2.0)
30
+ tty-color (~> 0.5)
31
+ tty-screen (~> 0.8)
32
+ tty-screen (0.8.1)
33
+ unicode-display_width (2.0.0)
34
+ unicode_utils (1.4.0)
10
35
  yard (0.9.26)
11
36
 
12
37
  PLATFORMS
13
38
  arm64-darwin-20
14
39
 
15
40
  DEPENDENCIES
41
+ readme_yard (~> 0.1)
16
42
  yard-readme!
17
43
 
18
44
  BUNDLED WITH
data/README.md CHANGED
@@ -1,35 +1,23 @@
1
- # Yard::Readme
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yard/readme`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'yard-readme'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install yard-readme
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- 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).
1
+ # yard-readme
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.
32
20
 
33
21
  ## Contributing
34
22
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yard-readme.
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mattruzicka/yard-readme.
data/README_YARD.md ADDED
@@ -0,0 +1,9 @@
1
+ # yard-readme
2
+
3
+ {@readme YARDReadme}
4
+
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
+
7
+ ## Contributing
8
+
9
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mattruzicka/yard-readme.
data/lib/yard-readme.rb CHANGED
@@ -3,6 +3,32 @@
3
3
  require 'yard'
4
4
  require_relative 'yard-readme/version'
5
5
  require_relative 'yard-readme/docstring_parser'
6
+ require_relative 'yard-readme/tag_factory'
6
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
+ #
7
27
  YARD::Docstring.default_parser = YARDReadme::DocstringParser
8
- YARD::Tags::Library.define_tag('README', :readme)
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)
@@ -1,5 +1,33 @@
1
1
  module YARDReadme
2
- class DocstringParser < YARD::DocstringParser
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
+
3
31
  def parse_content(content)
4
32
  content = content.split(/\r?\n/) if content.is_a?(String)
5
33
  return '' if !content || content.empty?
@@ -27,7 +55,8 @@ module YARDReadme
27
55
  docstring << parse_content(directive.expanded_text).chomp
28
56
  end
29
57
  else
30
- push_readme_text(docstring, buf) if tag_name == 'readme'
58
+ readme_text = parse_readme_text(buf) if parse_readme_text?(tag_name, buf)
59
+ docstring << readme_text if readme_text
31
60
  create_tag(tag_name, buf)
32
61
  end
33
62
  tag_name = nil
@@ -61,14 +90,13 @@ module YARDReadme
61
90
  docstring
62
91
  end
63
92
 
64
- def push_readme_text(docstring, buf)
65
- return if buf.empty?
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
66
97
 
67
- buf.split("\n").each do |buf_line|
68
- docstring << buf_line
69
- docstring << "\n"
70
- end
71
- docstring << "\n"
98
+ def parse_readme_text?(tag_name, buf)
99
+ tag_name == 'readme' && !buf.empty?
72
100
  end
73
101
  end
74
102
  end
@@ -0,0 +1,16 @@
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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module YARDReadme
2
- VERSION = '0.1.0'
4
+ VERSION = "0.3.0"
3
5
  end
data/yard-readme.gemspec CHANGED
@@ -3,19 +3,19 @@
3
3
  require_relative "lib/yard-readme/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "yard-readme"
7
- spec.version = YARDReadme::VERSION
8
- spec.authors = ["Matt Ruzicka"]
6
+ spec.name = "yard-readme"
7
+ spec.version = YARDReadme::VERSION
8
+ spec.authors = ["Matt Ruzicka"]
9
+ spec.license = "MIT"
9
10
 
10
- spec.summary = "Enhance your README with YARD"
11
- spec.description = "Generate your README using comments in your code"
12
- spec.homepage = 'https://github.com/mattruzicka/yard-readme'
11
+ spec.summary = "Enhance your README with YARD"
12
+ spec.description = "Generate your README using comments in your code"
13
+ spec.homepage = 'https://github.com/mattruzicka/yard-readme'
13
14
  spec.required_ruby_version = ">= 2.4.0"
14
15
 
15
16
  spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = 'https://github.com/mattruzicka/yard-readme'
17
- spec.metadata["changelog_uri"] = 'https://github.com/mattruzicka/yard-readme' \
18
- '/blob/master/CHANGELOG.md'
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -27,7 +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"
30
+ spec.add_dependency "yard", "~> 0.9.26"
31
+
32
+ spec.add_development_dependency 'readme_yard', "~> 0.1"
31
33
 
32
34
  # For more information and examples about making a new gem, checkout our
33
35
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-readme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ruzicka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-25 00:00:00.000000000 Z
11
+ date: 2021-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.26
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
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'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
27
41
  description: Generate your README using comments in your code
28
42
  email:
29
43
  executables: []
@@ -31,19 +45,23 @@ extensions: []
31
45
  extra_rdoc_files: []
32
46
  files:
33
47
  - ".gitignore"
48
+ - ".rubocop.yml"
34
49
  - ".yardopts"
35
50
  - CHANGELOG.md
36
51
  - Gemfile
37
52
  - Gemfile.lock
38
53
  - README.md
54
+ - README_YARD.md
39
55
  - bin/console
40
56
  - bin/setup
41
57
  - lib/yard-readme.rb
42
58
  - lib/yard-readme/docstring_parser.rb
59
+ - lib/yard-readme/tag_factory.rb
43
60
  - lib/yard-readme/version.rb
44
61
  - yard-readme.gemspec
45
62
  homepage: https://github.com/mattruzicka/yard-readme
46
- licenses: []
63
+ licenses:
64
+ - MIT
47
65
  metadata:
48
66
  homepage_uri: https://github.com/mattruzicka/yard-readme
49
67
  source_code_uri: https://github.com/mattruzicka/yard-readme