Skip to content
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

Move System Arguments page to Lookbook #2159

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ previews/docs/
test/snapshots/
test/snapshots/docs/
demo/test/snapshots/
previews/pages/*.md.erb
previews/pages/forms/inputs/*.md.erb
docs/content/adr/
docs/content/components/
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ gem "view_component", path: ENV["VIEW_COMPONENT_PATH"] if ENV["VIEW_COMPONENT_PA

group :test do
gem "webmock"

# Disallow v5.19 for now since it breaks mocha.
# See: https://github.com/freerange/mocha/issues/614
# Remove this line when mocha has fixed the issue
gem "minitest", "< 5.19"
end
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
minitest (5.17.0)
mocha (2.0.2)
minitest (5.18.1)
mocha (2.0.4)
ruby2_keywords (>= 0.0.5)
msgpack (1.7.0)
nio4r (2.5.9)
Expand Down Expand Up @@ -251,7 +251,7 @@ DEPENDENCIES
listen (~> 3.0)
lookbook (~> 2.0.0)
matrix (~> 0.4.2)
minitest (~> 5.0)
minitest (< 5.19)
mocha
primer_view_components!
pry
Expand Down
31 changes: 31 additions & 0 deletions lib/primer/yard/lookbook_pages_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def generate
each_component do |component_ref|
page_for(component_ref).generate
end
generate_system_args_docs
end

def page_for(component_ref)
Expand All @@ -194,6 +195,36 @@ def view_context
def each_component(&block)
manifest.each(&block)
end

def generate_system_args_docs
docs = registry.find(Primer::BaseComponent)

path = File.expand_path(
File.join(
*%w[.. .. .. previews pages system-arguments.md.erb]
), __dir__
)

data = {
"description_md" => docs.base_docstring.to_s,
"args_md" => view_context.render(inline: docs.constructor.base_docstring)
}

frontmatter = {
"title" => "System arguments",
"id" => "system_arguments",
"data" => data
}

File.write(
path, <<~ERB
#{YAML.dump(frontmatter)}
---
<%= @page.data[:description_md] %>
<%= @page.data[:args_md] %>
ERB
)
end
end
end
end
Expand Down
Loading