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

Adding lookbook links to docs output #1376

Merged
merged 8 commits into from
Sep 15, 2022
Merged
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions lib/tasks/docs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ namespace :docs do
f.puts("status: #{data[:status]}")
f.puts("source: #{data[:source]}")
f.puts("storybook: #{data[:storybook]}")
f.puts("lookbook: #{data[:lookbook]}") if preview_exists?(component)
f.puts("---")
f.puts
f.puts("import Example from '#{data[:example_path]}'")
Expand Down Expand Up @@ -467,6 +468,7 @@ namespace :docs do
status: status.capitalize,
source: source_url(component),
storybook: storybook_url(component),
lookbook: lookbook_url(component),
path: "docs/content/components/#{status_path}#{short_name.downcase}.md",
example_path: example_path(component),
require_js_path: require_js_path(component)
Expand All @@ -485,6 +487,18 @@ namespace :docs do
"https://primer.style/view-components/stories/?path=/story/#{path}"
end

def lookbook_url(component)
path = component.name.underscore

"https://primer.style/view-components/lookbook/inspect/#{path}/default/"
jonrohan marked this conversation as resolved.
Show resolved Hide resolved
end

def preview_exists?(component)
path = component.name.underscore

File.exist?("test/previews/#{path}_preview.rb")
end

def example_path(component)
example_path = "../../src/@primer/gatsby-theme-doctocat/components/example"
example_path = "../#{example_path}" if status_module?(component)
Expand Down