diff --git a/.gitignore b/.gitignore index 9e539080cd..d2900227c9 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/Gemfile b/Gemfile index 9c582fcf27..e9f7587a1e 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index b810a1d77c..f8e9b09f30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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 diff --git a/lib/primer/yard/lookbook_pages_backend.rb b/lib/primer/yard/lookbook_pages_backend.rb index 0ceb2404f9..cbc494c4f1 100644 --- a/lib/primer/yard/lookbook_pages_backend.rb +++ b/lib/primer/yard/lookbook_pages_backend.rb @@ -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) @@ -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