-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#267) Don’t show “Public X” header without contents #314
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -50,6 +50,33 @@ module PuppetStrings::Markdown | |||||||
# ") inherits foo::bar {\n" + | ||||||||
# "}"} | ||||||||
class Base | ||||||||
# Set or return the name of the group | ||||||||
# | ||||||||
# @param [Optional[String]] Name of the group to set | ||||||||
# @return [String] Name of the group | ||||||||
def self.group_name(name = nil) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts about splitting the functionality in Same comment applies to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually tried doing class << self
attr_accessor :group_name
attr_accessor :yard_types
end but I ran into a few problems. One was that it interpreted I wanted it to look more like functions like I don’t have a real good sense for the Ruby Way anymore… been writing other languages for too long. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. I suppose this is good enough. |
||||||||
@group_name = name if name | ||||||||
@group_name | ||||||||
end | ||||||||
|
||||||||
# Set or return the types registered with YARD | ||||||||
# | ||||||||
# @param [Optional[Array[Symbol]]] Array of symbols registered with YARD to set | ||||||||
# @return [Array[Symbol]] Array of symbols registered with YARD | ||||||||
def self.yard_types(types = nil) | ||||||||
@yard_types = types if types | ||||||||
@yard_types | ||||||||
end | ||||||||
|
||||||||
# @return [Array] list of items | ||||||||
def self.items | ||||||||
yard_types | ||||||||
.flat_map { |type| YARD::Registry.all(type) } | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL about https://ruby-doc.org/core-2.7.1/Enumerable.html#method-i-flat_map. Neat! |
||||||||
.sort_by(&:name) | ||||||||
.map(&:to_hash) | ||||||||
.map { |i| new(i) } | ||||||||
Comment on lines
+76
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can combine both maps
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦 |
||||||||
end | ||||||||
|
||||||||
def initialize(registry, component_type) | ||||||||
@type = component_type | ||||||||
@registry = registry | ||||||||
|
@@ -200,17 +227,4 @@ def clean_link(input) | |||||||
input.tr('^a-zA-Z0-9_-', '-') | ||||||||
end | ||||||||
end | ||||||||
|
||||||||
# Helper function to load an ERB template. | ||||||||
# | ||||||||
# @param [String] path The full path to the template file. | ||||||||
# @return [ERB] Template | ||||||||
def self.erb(path) | ||||||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') | ||||||||
ERB.new(File.read(path), trim_mode: '-') | ||||||||
else | ||||||||
# This outputs warnings in Ruby 2.6+. | ||||||||
ERB.new(File.read(path), nil, '-') | ||||||||
end | ||||||||
end | ||||||||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this, but later on I realized you could also write it with the
if
outside ofdef
so it's only ran once, though it probably doesn't matter much.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm… I thought about it, but I’m inclined not to since it ends up duplicating the doc comment. Or maybe I should just put the docs above the outer
if
if I do that? Pretty sure the performance difference will be negligible.