boondoc 0.1.0 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'shellwords'
3
+ require "shellwords"
4
4
 
5
5
  module Boondoc
6
6
  # The part of a project's `.yardopts` that Boondoc understands.
@@ -15,21 +15,48 @@ module Boondoc
15
15
  # Boondoc::Yardopts.parse('--title Foo -o doc lib - CHANGELOG.md').settings
16
16
  # # => { title: "Foo", sources: ["lib"], files: ["CHANGELOG.md"] }
17
17
  class Yardopts
18
- FILE = '.yardopts'
18
+ FILE = ".yardopts"
19
19
  # Long options of the yard gem that take an argument.
20
20
  ARGUMENT_OPTIONS = %w[
21
- --load --plugin --db --exclude --api --no-api --hide-api --default-return --query --title
22
- --readme --main --files --asset --output-dir --markup --markup-provider --charset --template
23
- --template-path --format --locale --po-dir --tag --type-tag --type-name-tag --name-tag
24
- --title-tag --hide-tag --transitive-tag --non-transitive-tag
21
+ --load
22
+ --plugin
23
+ --db
24
+ --exclude
25
+ --api
26
+ --no-api
27
+ --hide-api
28
+ --default-return
29
+ --query
30
+ --title
31
+ --readme
32
+ --main
33
+ --files
34
+ --asset
35
+ --output-dir
36
+ --markup
37
+ --markup-provider
38
+ --charset
39
+ --template
40
+ --template-path
41
+ --format
42
+ --locale
43
+ --po-dir
44
+ --tag
45
+ --type-tag
46
+ --type-name-tag
47
+ --name-tag
48
+ --title-tag
49
+ --hide-tag
50
+ --transitive-tag
51
+ --non-transitive-tag
25
52
  ].freeze
26
53
  # Long options whose argument is optional; it is the next token unless that starts with `-`.
27
54
  OPTIONAL_ARGUMENT_OPTIONS = %w[--use-cache --yardopts --no-yardopts --embed-mixin].freeze
28
55
  SHORT_ARGUMENT_OPTIONS = {
29
- 'b' => '--db', 'e' => '--load', 'o' => '--output-dir', 'm' => '--markup', 'M' => '--markup-provider',
30
- 't' => '--template', 'p' => '--template-path', 'f' => '--format', 'r' => '--readme'
56
+ "b" => "--db", "e" => "--load", "o" => "--output-dir", "m" => "--markup", "M" => "--markup-provider",
57
+ "t" => "--template", "p" => "--template-path", "f" => "--format", "r" => "--readme"
31
58
  }.freeze
32
- SHORT_OPTIONAL_ARGUMENT_OPTIONS = { 'c' => '--use-cache' }.freeze
59
+ SHORT_OPTIONAL_ARGUMENT_OPTIONS = { "c" => "--use-cache" }.freeze
33
60
  NON_RUBY_SOURCE = /\.(?:c|cc|cpp|cxx|h|hpp|y)\z/
34
61
  # How long a pattern from `--exclude` may take to match one path.
35
62
  REGEXP_TIMEOUT = 1.0
@@ -86,9 +113,9 @@ module Boondoc
86
113
  notes = []
87
114
  if output_dir && File.expand_path(output_dir, root) != File.expand_path(output, root)
88
115
  notes << "ignoring --output-dir #{output_dir} from #{FILE}; writing to #{output} " \
89
- '(set output in .boondoc.yml or pass -o to change)'
116
+ "(set output in .boondoc.yml or pass -o to change)"
90
117
  end
91
- notes << "ignoring from #{FILE}: #{ignored.join(', ')}" if ignored.any?
118
+ notes << "ignoring from #{FILE}: #{ignored.join(", ")}" if ignored.any?
92
119
  notes
93
120
  end
94
121
 
@@ -99,9 +126,9 @@ module Boondoc
99
126
  extra = false
100
127
  until tokens.empty?
101
128
  token = tokens.shift
102
- if token == '-' then extra = true
129
+ if token == "-" then extra = true
103
130
  elsif extra then @files << token
104
- elsif token.start_with?('-') then read_option(token, tokens)
131
+ elsif token.start_with?("-") then read_option(token, tokens)
105
132
  else add_source(token)
106
133
  end
107
134
  end
@@ -116,36 +143,36 @@ module Boondoc
116
143
  def takes_argument?(name, rest)
117
144
  return false if rest.empty?
118
145
 
119
- ARGUMENT_OPTIONS.include?(name) || (OPTIONAL_ARGUMENT_OPTIONS.include?(name) && !rest.first.start_with?('-'))
146
+ ARGUMENT_OPTIONS.include?(name) || (OPTIONAL_ARGUMENT_OPTIONS.include?(name) && !rest.first.start_with?("-"))
120
147
  end
121
148
 
122
149
  # @return [Array(String, String)] the canonical long name (or the token itself) and its inline value, if any
123
150
  def split_option(token)
124
- return token.split('=', 2).values_at(0, 1) if token.start_with?('--')
151
+ return token.split("=", 2).values_at(0, 1) if token.start_with?("--")
125
152
 
126
153
  letter = token[1]
127
154
  long = SHORT_ARGUMENT_OPTIONS[letter] || SHORT_OPTIONAL_ARGUMENT_OPTIONS[letter]
128
155
  return [token, nil] unless long
129
156
 
130
- [long, token.length > 2 ? token[2..] : nil]
157
+ [long, (token.length > 2) ? token[2..] : nil]
131
158
  end
132
159
 
133
160
  def apply(name, value)
134
161
  case name
135
- when '--output-dir' then @output_dir = value
136
- when '--title' then @settings[:title] = value
137
- when '--readme', '--main' then @settings[:readme] = value
138
- when '--files', '--asset' then add_list(name, value)
139
- when '--private', '--protected' then @settings[name.delete_prefix('--').to_sym] = true
140
- when '--exclude' then add_exclude(value)
162
+ when "--output-dir" then @output_dir = value
163
+ when "--title" then @settings[:title] = value
164
+ when "--readme", "--main" then @settings[:readme] = value
165
+ when "--files", "--asset" then add_list(name, value)
166
+ when "--private", "--protected" then @settings[name.delete_prefix("--").to_sym] = true
167
+ when "--exclude" then add_exclude(value)
141
168
  else @ignored << name
142
169
  end
143
170
  end
144
171
 
145
172
  # `--files` and `--asset` take comma-separated lists, as YARD does for `--files`.
146
173
  def add_list(name, value)
147
- list = name == '--asset' ? @assets : @files
148
- list.concat(value.to_s.split(','))
174
+ list = (name == "--asset") ? @assets : @files
175
+ list.concat(value.to_s.split(","))
149
176
  end
150
177
 
151
178
  def add_source(glob)
data/lib/boondoc.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'prism'
3
+ require "prism"
4
4
 
5
- require_relative 'boondoc/version'
5
+ require_relative "boondoc/version"
6
6
 
7
7
  # Markdown-only API documentation for Ruby.
8
8
  #
@@ -14,35 +14,35 @@ module Boondoc
14
14
  class Error < StandardError; end
15
15
  end
16
16
 
17
- require_relative 'boondoc/reporter'
18
- require_relative 'boondoc/containment'
19
- require_relative 'boondoc/yardopts'
20
- require_relative 'boondoc/config'
21
- require_relative 'boondoc/markdown'
22
- require_relative 'boondoc/model/docstring'
23
- require_relative 'boondoc/model/code_object'
24
- require_relative 'boondoc/model/registry'
25
- require_relative 'boondoc/type_parser'
26
- require_relative 'boondoc/docstring_parser'
27
- require_relative 'boondoc/frontend/comments'
28
- require_relative 'boondoc/frontend/visitor'
29
- require_relative 'boondoc/frontend/prism_parser'
30
- require_relative 'boondoc/yard_bridge'
31
- require_relative 'boondoc/references'
32
- require_relative 'boondoc/filter'
33
- require_relative 'boondoc/path_map'
34
- require_relative 'boondoc/links'
35
- require_relative 'boondoc/assets'
36
- require_relative 'boondoc/stitcher'
37
- require_relative 'boondoc/core_constants'
38
- require_relative 'boondoc/linker'
39
- require_relative 'boondoc/context'
40
- require_relative 'boondoc/renderer/base'
41
- require_relative 'boondoc/renderer/docstring'
42
- require_relative 'boondoc/renderer/method_section'
43
- require_relative 'boondoc/renderer/namespace_page'
44
- require_relative 'boondoc/renderer/index'
45
- require_relative 'boondoc/writer'
46
- require_relative 'boondoc/generator'
47
- require_relative 'boondoc/preview'
48
- require_relative 'boondoc/cli'
17
+ require_relative "boondoc/reporter"
18
+ require_relative "boondoc/containment"
19
+ require_relative "boondoc/yardopts"
20
+ require_relative "boondoc/config"
21
+ require_relative "boondoc/markdown"
22
+ require_relative "boondoc/model/docstring"
23
+ require_relative "boondoc/model/code_object"
24
+ require_relative "boondoc/model/registry"
25
+ require_relative "boondoc/type_parser"
26
+ require_relative "boondoc/docstring_parser"
27
+ require_relative "boondoc/frontend/comments"
28
+ require_relative "boondoc/frontend/visitor"
29
+ require_relative "boondoc/frontend/prism_parser"
30
+ require_relative "boondoc/yard_bridge"
31
+ require_relative "boondoc/references"
32
+ require_relative "boondoc/filter"
33
+ require_relative "boondoc/path_map"
34
+ require_relative "boondoc/links"
35
+ require_relative "boondoc/assets"
36
+ require_relative "boondoc/stitcher"
37
+ require_relative "boondoc/core_constants"
38
+ require_relative "boondoc/linker"
39
+ require_relative "boondoc/context"
40
+ require_relative "boondoc/renderer/base"
41
+ require_relative "boondoc/renderer/docstring"
42
+ require_relative "boondoc/renderer/method_section"
43
+ require_relative "boondoc/renderer/namespace_page"
44
+ require_relative "boondoc/renderer/index"
45
+ require_relative "boondoc/writer"
46
+ require_relative "boondoc/generator"
47
+ require_relative "boondoc/preview"
48
+ require_relative "boondoc/cli"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boondoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Sharp
@@ -13,30 +13,36 @@ dependencies:
13
13
  name: prism
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '1.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
- - - "~>"
26
+ - - ">="
24
27
  - !ruby/object:Gem::Version
25
28
  version: '1.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3'
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: thor
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - "~>"
31
37
  - !ruby/object:Gem::Version
32
- version: '1.3'
38
+ version: '1.2'
33
39
  type: :runtime
34
40
  prerelease: false
35
41
  version_requirements: !ruby/object:Gem::Requirement
36
42
  requirements:
37
43
  - - "~>"
38
44
  - !ruby/object:Gem::Version
39
- version: '1.3'
45
+ version: '1.2'
40
46
  description: 'boondoc reads YARD-style tags from Ruby source using Prism and writes
41
47
  plain GitHub-flavored markdown: one file per class or module, with working relative
42
48
  links, plus your README and guides stitched in. No HTML, no site to deploy and host.'
@@ -92,7 +98,7 @@ licenses:
92
98
  - MIT
93
99
  metadata:
94
100
  homepage_uri: https://github.com/joe-sharp/boondoc
95
- source_code_uri: https://github.com/joe-sharp/boondoc/tree/v0.1.0
101
+ source_code_uri: https://github.com/joe-sharp/boondoc/tree/v0.2.0
96
102
  bug_tracker_uri: https://github.com/joe-sharp/boondoc/issues
97
103
  changelog_uri: https://github.com/joe-sharp/boondoc/blob/main/CHANGELOG.md
98
104
  rubygems_mfa_required: 'true'