-
Notifications
You must be signed in to change notification settings - Fork 0
Improve documentation visuals #81
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
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
242932a
Prettier code examples
koppen d5f338a
Use the first paragraph as introduction
koppen 1951cb6
Render previews named example as part of the intro
koppen 58db101
Render each scenario as a separate example
koppen dfbeb3b
Include preview notes in the docs page
koppen a9f778e
Group API references at the bottom of the page
koppen 0399004
Create helper for rendering docstrings
koppen 26ccbe6
Use Yards htmlify helper to render docstrings
koppen b317a10
Remove forced line breaks
koppen 8891ae4
Make links in documentation clickable
koppen 57af274
Link component names to their docs
koppen 0342975
Improve Breadcrumb documentation
koppen 7cd882d
Improve Card documentation
koppen 59daf6a
Improve Input documentation
koppen 9801ec6
Improve InputField documentation
koppen 43aa893
Improve Link documentation
koppen 336f99a
Improve Toast documentation
koppen 0741c37
Extract headline components
koppen 113d077
Increase whitespace
koppen cd1ba85
Use Flowbite 4 semantic colors
koppen f105434
Guard against nil values
koppen ad2140a
Prefer preview_class_name
koppen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ gem "decant" | |
| gem "kramdown" | ||
| gem "kramdown-parser-gfm" | ||
| gem "lookbook", ">= 2.3.11" | ||
| gem "rails_autolink" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <pre><code class="block bg-neutral-tertiary px-4 py-2 rounded-lg"><%= content %></code></pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Docs::CodeExample < ViewComponent::Base | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class Docs::Headline < ViewComponent::Base | ||
| def call | ||
| content_tag(tag, content, class: classes) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class Docs::Headline::H1 < Docs::Headline | ||
| def classes | ||
| "mb-4 text-4xl tracking-tight font-bold text-heading" | ||
| end | ||
|
|
||
| def tag | ||
| :h1 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class Docs::Headline::H2 < Docs::Headline | ||
| def classes | ||
| "mb-4 mt-8 text-2xl font-bold text-heading" | ||
| end | ||
|
|
||
| def tag | ||
| :h2 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class Docs::Headline::H3 < Docs::Headline | ||
| def classes | ||
| "mt-4 mb-2 text-xl font-bold text-heading" | ||
| end | ||
|
|
||
| def tag | ||
| :h3 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class Docs::Headline::H4 < Docs::Headline | ||
| def classes | ||
| "mt-4 text-md font-bold text-heading" | ||
| end | ||
|
|
||
| def tag | ||
| :h4 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| require "rails_autolink" | ||
|
|
||
| module FormattingHelper | ||
| class DocstringRenderer | ||
| include YARD::Templates::Helpers::BaseHelper | ||
| include YARD::Templates::Helpers::HtmlHelper | ||
|
|
||
| Options = Data.define(:markup) | ||
|
|
||
| attr_reader :view_context | ||
|
|
||
| def initialize(content, view_context:, code_object: nil) | ||
| @content = content | ||
| @code_object = code_object | ||
| @view_context = view_context | ||
| end | ||
|
|
||
| # Called by YARD::Templates::Helpers::HtmlHelper#htmlify to render the | ||
| # docstring content. The default implementation simply returns the content | ||
| # as is, but you can override this method to provide custom rendering logic | ||
| # based on the specified markup format. | ||
| def html_markup_markdown(content) | ||
| return "" unless content | ||
| return "" unless content.strip.present? | ||
koppen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| output = Kramdown::Document.new(content, input: "GFM").to_html | ||
| remove_line_breaks(output) | ||
| end | ||
|
|
||
| def render | ||
| htmlify(@content) | ||
koppen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| private | ||
|
|
||
| def object | ||
| # Required by YARD::Templates::Helpers::HtmlHelper#resolve_links | ||
| @code_object | ||
| end | ||
|
|
||
| def options | ||
| @options ||= Options.new( | ||
| markup: :markdown | ||
| ) | ||
| end | ||
|
|
||
| def remove_line_breaks(text) | ||
| text.gsub("<br />", " ") | ||
| end | ||
|
|
||
| def linkify(name, title) | ||
| code_object = Yard.code_object(name) | ||
| if code_object | ||
| view_context.link_to(title || name, view_context.docs_component_path(code_object.path)) | ||
| else | ||
| title || name | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def render_docstring(content, code_object: nil) | ||
| html = DocstringRenderer.new( | ||
| content, | ||
| code_object: code_object, | ||
| view_context: self | ||
| ).render.html_safe | ||
| auto_link(html) | ||
| end | ||
|
|
||
| def render_markdown(content) | ||
| Kramdown::Document.new(content, input: "GFM").to_html.html_safe | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.