yard-readme 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d4ec34f12f41177c0652dcf498e833a03b2492e0faf1c487ee40b149bf41b2eb
4
+ data.tar.gz: 362213c9dd24df82f3396dd81218fe623050d91eb7c59adaed04fbe3587d44b9
5
+ SHA512:
6
+ metadata.gz: ecda196fad92caf901bbe43c0661dc961fc8abc39ee6aff954144167b6741e6ac5f6d4f6679fbf48a3cb849f64840ff7841039860225da57bc9e6f42a9e0a98c
7
+ data.tar.gz: 854dbe3d3d9ae01097edc0681d4f267248bb9db5107c01f49a8238131316ceab9f622e11253e1addce0c6d60d67d81c5ddcb659ad4129165a25a7199565d9cca
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --plugin readme
2
+ lib/**/*.rb
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-07-25
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in yard-readme.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yard-readme (0.1.0)
5
+ yard
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ yard (0.9.26)
11
+
12
+ PLATFORMS
13
+ arm64-darwin-20
14
+
15
+ DEPENDENCIES
16
+ yard-readme!
17
+
18
+ BUNDLED WITH
19
+ 2.2.24
data/README.md ADDED
@@ -0,0 +1,35 @@
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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yard-readme.
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "yard-readme"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yard'
4
+ require_relative 'yard-readme/version'
5
+ require_relative 'yard-readme/docstring_parser'
6
+
7
+ YARD::Docstring.default_parser = YARDReadme::DocstringParser
8
+ YARD::Tags::Library.define_tag('README', :readme)
@@ -0,0 +1,74 @@
1
+ module YARDReadme
2
+ class DocstringParser < YARD::DocstringParser
3
+ def parse_content(content)
4
+ content = content.split(/\r?\n/) if content.is_a?(String)
5
+ return '' if !content || content.empty?
6
+ docstring = String.new("")
7
+
8
+ indent = content.first[/^\s*/].length
9
+ last_indent = 0
10
+ orig_indent = 0
11
+ directive = false
12
+ last_line = ""
13
+ tag_name = nil
14
+ tag_buf = []
15
+
16
+ (content + ['']).each_with_index do |line, index|
17
+ indent = line[/^\s*/].length
18
+ empty = (line =~ /^\s*$/ ? true : false)
19
+ done = content.size == index
20
+
21
+ if tag_name && (((indent < orig_indent && !empty) || done ||
22
+ (indent == 0 && !empty)) || (indent <= last_indent && line =~ META_MATCH))
23
+ buf = tag_buf.join("\n")
24
+ if directive || tag_is_directive?(tag_name)
25
+ directive = create_directive(tag_name, buf)
26
+ if directive
27
+ docstring << parse_content(directive.expanded_text).chomp
28
+ end
29
+ else
30
+ push_readme_text(docstring, buf) if tag_name == 'readme'
31
+ create_tag(tag_name, buf)
32
+ end
33
+ tag_name = nil
34
+ tag_buf = []
35
+ directive = false
36
+ orig_indent = 0
37
+ end
38
+
39
+ # Found a meta tag
40
+ if line =~ META_MATCH
41
+ directive = $1
42
+ tag_name = $2
43
+ tag_buf = [($3 || '')]
44
+ elsif tag_name && indent >= orig_indent && !empty
45
+ orig_indent = indent if orig_indent == 0
46
+ # Extra data added to the tag on the next line
47
+ last_empty = last_line =~ /^[ \t]*$/ ? true : false
48
+
49
+ tag_buf << '' if last_empty
50
+ tag_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
51
+ elsif !tag_name
52
+ # Regular docstring text
53
+ docstring << line
54
+ docstring << "\n"
55
+ end
56
+
57
+ last_indent = indent
58
+ last_line = line
59
+ end
60
+
61
+ docstring
62
+ end
63
+
64
+ def push_readme_text(docstring, buf)
65
+ return if buf.empty?
66
+
67
+ buf.split("\n").each do |buf_line|
68
+ docstring << buf_line
69
+ docstring << "\n"
70
+ end
71
+ docstring << "\n"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module YARDReadme
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/yard-readme/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "yard-readme"
7
+ spec.version = YARDReadme::VERSION
8
+ spec.authors = ["Matt Ruzicka"]
9
+
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'
13
+ spec.required_ruby_version = ">= 2.4.0"
14
+
15
+ 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'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ spec.add_dependency "yard"
31
+
32
+ # For more information and examples about making a new gem, checkout our
33
+ # guide at: https://bundler.io/guides/creating_gem.html
34
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-readme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Ruzicka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Generate your README using comments in your code
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".gitignore"
34
+ - ".yardopts"
35
+ - CHANGELOG.md
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - bin/console
40
+ - bin/setup
41
+ - lib/yard-readme.rb
42
+ - lib/yard-readme/docstring_parser.rb
43
+ - lib/yard-readme/version.rb
44
+ - yard-readme.gemspec
45
+ homepage: https://github.com/mattruzicka/yard-readme
46
+ licenses: []
47
+ metadata:
48
+ homepage_uri: https://github.com/mattruzicka/yard-readme
49
+ source_code_uri: https://github.com/mattruzicka/yard-readme
50
+ changelog_uri: https://github.com/mattruzicka/yard-readme/blob/master/CHANGELOG.md
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.4.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.2.3
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Enhance your README with YARD
70
+ test_files: []