docyard 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/lib/docyard/build/static_generator.rb +2 -43
- data/lib/docyard/builder.rb +14 -4
- data/lib/docyard/cli.rb +6 -3
- data/lib/docyard/components/aliases.rb +29 -0
- data/lib/docyard/components/processors/callout_processor.rb +124 -0
- data/lib/docyard/components/processors/code_block_diff_preprocessor.rb +106 -0
- data/lib/docyard/components/processors/code_block_focus_preprocessor.rb +79 -0
- data/lib/docyard/components/processors/code_block_options_preprocessor.rb +78 -0
- data/lib/docyard/components/processors/code_block_processor.rb +175 -0
- data/lib/docyard/components/processors/code_snippet_import_preprocessor.rb +127 -0
- data/lib/docyard/components/processors/heading_anchor_processor.rb +39 -0
- data/lib/docyard/components/processors/icon_processor.rb +53 -0
- data/lib/docyard/components/processors/table_of_contents_processor.rb +68 -0
- data/lib/docyard/components/processors/table_wrapper_processor.rb +22 -0
- data/lib/docyard/components/processors/tabs_processor.rb +48 -0
- data/lib/docyard/components/support/code_block/feature_extractor.rb +117 -0
- data/lib/docyard/components/support/code_block/icon_detector.rb +44 -0
- data/lib/docyard/components/support/code_block/line_parser.rb +84 -0
- data/lib/docyard/components/support/code_block/line_wrapper.rb +50 -0
- data/lib/docyard/components/support/code_block/patterns.rb +55 -0
- data/lib/docyard/components/support/code_detector.rb +61 -0
- data/lib/docyard/components/support/tabs/icon_detector.rb +62 -0
- data/lib/docyard/components/support/tabs/parser.rb +195 -0
- data/lib/docyard/components/support/tabs/range_finder.rb +46 -0
- data/lib/docyard/config/branding_resolver.rb +74 -0
- data/lib/docyard/{constants.rb → config/constants.rb} +1 -0
- data/lib/docyard/config.rb +10 -1
- data/lib/docyard/{prev_next_builder.rb → navigation/prev_next_builder.rb} +2 -2
- data/lib/docyard/{sidebar → navigation/sidebar}/renderer.rb +3 -14
- data/lib/docyard/{sidebar → navigation/sidebar}/tree_builder.rb +9 -2
- data/lib/docyard/{sidebar_builder.rb → navigation/sidebar_builder.rb} +3 -15
- data/lib/docyard/{icons → rendering/icons}/phosphor.rb +4 -1
- data/lib/docyard/{markdown.rb → rendering/markdown.rb} +14 -13
- data/lib/docyard/{renderer.rb → rendering/renderer.rb} +20 -17
- data/lib/docyard/search/build_indexer.rb +74 -0
- data/lib/docyard/search/dev_indexer.rb +110 -0
- data/lib/docyard/search/pagefind_support.rb +31 -0
- data/lib/docyard/{asset_handler.rb → server/asset_handler.rb} +1 -1
- data/lib/docyard/{server.rb → server/dev_server.rb} +32 -9
- data/lib/docyard/{preview_server.rb → server/preview_server.rb} +1 -1
- data/lib/docyard/{rack_application.rb → server/rack_application.rb} +52 -49
- data/lib/docyard/server/resolution_result.rb +29 -0
- data/lib/docyard/{router.rb → server/router.rb} +4 -4
- data/lib/docyard/templates/assets/css/components/search.css +549 -0
- data/lib/docyard/templates/assets/css/layout.css +15 -1
- data/lib/docyard/templates/assets/js/components/search.js +685 -0
- data/lib/docyard/templates/layouts/default.html.erb +14 -2
- data/lib/docyard/templates/partials/_code_block.html.erb +1 -1
- data/lib/docyard/templates/partials/_heading_anchor.html.erb +1 -1
- data/lib/docyard/templates/partials/_prev_next.html.erb +1 -1
- data/lib/docyard/templates/partials/_search_modal.html.erb +45 -0
- data/lib/docyard/templates/partials/_search_trigger.html.erb +22 -0
- data/lib/docyard/utils/html_helpers.rb +14 -0
- data/lib/docyard/utils/path_resolver.rb +2 -1
- data/lib/docyard/utils/url_helpers.rb +20 -0
- data/lib/docyard/version.rb +1 -1
- data/lib/docyard.rb +22 -15
- metadata +57 -46
- data/lib/docyard/components/callout_processor.rb +0 -121
- data/lib/docyard/components/code_block_diff_preprocessor.rb +0 -104
- data/lib/docyard/components/code_block_feature_extractor.rb +0 -113
- data/lib/docyard/components/code_block_focus_preprocessor.rb +0 -77
- data/lib/docyard/components/code_block_icon_detector.rb +0 -40
- data/lib/docyard/components/code_block_line_wrapper.rb +0 -46
- data/lib/docyard/components/code_block_options_preprocessor.rb +0 -76
- data/lib/docyard/components/code_block_patterns.rb +0 -51
- data/lib/docyard/components/code_block_processor.rb +0 -176
- data/lib/docyard/components/code_detector.rb +0 -59
- data/lib/docyard/components/code_line_parser.rb +0 -80
- data/lib/docyard/components/code_snippet_import_preprocessor.rb +0 -125
- data/lib/docyard/components/heading_anchor_processor.rb +0 -34
- data/lib/docyard/components/icon_detector.rb +0 -57
- data/lib/docyard/components/icon_processor.rb +0 -51
- data/lib/docyard/components/table_of_contents_processor.rb +0 -64
- data/lib/docyard/components/table_wrapper_processor.rb +0 -18
- data/lib/docyard/components/tabs_parser.rb +0 -191
- data/lib/docyard/components/tabs_processor.rb +0 -44
- data/lib/docyard/components/tabs_range_finder.rb +0 -42
- data/lib/docyard/routing/resolution_result.rb +0 -31
- /data/lib/docyard/{sidebar → navigation/sidebar}/config_parser.rb +0 -0
- /data/lib/docyard/{sidebar → navigation/sidebar}/file_system_scanner.rb +0 -0
- /data/lib/docyard/{sidebar → navigation/sidebar}/item.rb +0 -0
- /data/lib/docyard/{sidebar → navigation/sidebar}/title_extractor.rb +0 -0
- /data/lib/docyard/{icons → rendering/icons}/LICENSE.phosphor +0 -0
- /data/lib/docyard/{icons → rendering/icons}/file_types.rb +0 -0
- /data/lib/docyard/{icons.rb → rendering/icons.rb} +0 -0
- /data/lib/docyard/{language_mapping.rb → rendering/language_mapping.rb} +0 -0
- /data/lib/docyard/{file_watcher.rb → server/file_watcher.rb} +0 -0
- /data/lib/docyard/{errors.rb → utils/errors.rb} +0 -0
- /data/lib/docyard/{logging.rb → utils/logging.rb} +0 -0
|
@@ -43,7 +43,15 @@
|
|
|
43
43
|
<% end %>
|
|
44
44
|
</a>
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
<% if @search_enabled %>
|
|
47
|
+
<div class="header-center">
|
|
48
|
+
<%= render_partial('_search_trigger') %>
|
|
49
|
+
</div>
|
|
50
|
+
<% end %>
|
|
51
|
+
|
|
52
|
+
<div class="header-actions">
|
|
53
|
+
<%= render_partial('_theme_toggle') %>
|
|
54
|
+
</div>
|
|
47
55
|
</div>
|
|
48
56
|
</header>
|
|
49
57
|
|
|
@@ -68,7 +76,7 @@
|
|
|
68
76
|
|
|
69
77
|
<!-- Main content area -->
|
|
70
78
|
<div class="layout-main">
|
|
71
|
-
<main id="main-content" class="content">
|
|
79
|
+
<main id="main-content" class="content" data-pagefind-body>
|
|
72
80
|
<%= @content %>
|
|
73
81
|
|
|
74
82
|
<!-- Previous/Next Navigation -->
|
|
@@ -80,6 +88,10 @@
|
|
|
80
88
|
<%= render_partial('_table_of_contents') %>
|
|
81
89
|
</div>
|
|
82
90
|
|
|
91
|
+
<% if @search_enabled %>
|
|
92
|
+
<%= render_partial('_search_modal') %>
|
|
93
|
+
<% end %>
|
|
94
|
+
|
|
83
95
|
<script src="/assets/js/theme.js"></script>
|
|
84
96
|
<script src="/assets/js/components.js"></script>
|
|
85
97
|
<script src="/assets/js/reload.js"></script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% has_diff = @diff_lines&.any? %><% has_focus = @focus_lines&.any? %><% has_error = @error_lines&.any? %><% has_warning = @warning_lines&.any? %><% has_title = !@title.nil? && !@title.empty? %><div class="docyard-code-block<%= ' docyard-code-block--line-numbers' if @show_line_numbers %><%= ' docyard-code-block--highlighted' if @highlights&.any? %><%= ' docyard-code-block--diff' if has_diff %><%= ' docyard-code-block--has-focus' if has_focus %><%= ' docyard-code-block--has-error' if has_error %><%= ' docyard-code-block--has-warning' if has_warning %><%= ' docyard-code-block--titled' if has_title %>">
|
|
1
|
+
<% has_diff = @diff_lines&.any? %><% has_focus = @focus_lines&.any? %><% has_error = @error_lines&.any? %><% has_warning = @warning_lines&.any? %><% has_title = !@title.nil? && !@title.empty? %><div class="docyard-code-block<%= ' docyard-code-block--line-numbers' if @show_line_numbers %><%= ' docyard-code-block--highlighted' if @highlights&.any? %><%= ' docyard-code-block--diff' if has_diff %><%= ' docyard-code-block--has-focus' if has_focus %><%= ' docyard-code-block--has-error' if has_error %><%= ' docyard-code-block--has-warning' if has_warning %><%= ' docyard-code-block--titled' if has_title %>" data-pagefind-ignore>
|
|
2
2
|
<% if has_title %>
|
|
3
3
|
<div class="docyard-code-block__header">
|
|
4
4
|
<% if @icon %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<a href="#<%= @id %>" class="heading-anchor" aria-label="Link to this section" data-heading-id="<%= @id %>">#</a>
|
|
1
|
+
<a href="#<%= @id %>" class="heading-anchor" aria-label="Link to this section" data-heading-id="<%= @id %>" data-pagefind-ignore>#</a>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<div class="search-modal" role="dialog" aria-modal="true" aria-label="Search documentation" data-search-modal data-pagefind-ignore hidden>
|
|
2
|
+
<div class="search-modal-backdrop" data-search-backdrop></div>
|
|
3
|
+
<div class="search-modal-container">
|
|
4
|
+
<div class="search-modal-header">
|
|
5
|
+
<svg class="search-modal-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true">
|
|
6
|
+
<path d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path>
|
|
7
|
+
</svg>
|
|
8
|
+
<input
|
|
9
|
+
type="text"
|
|
10
|
+
class="search-modal-input"
|
|
11
|
+
placeholder="<%= @search_placeholder || 'Search documentation...' %>"
|
|
12
|
+
autocomplete="off"
|
|
13
|
+
autocorrect="off"
|
|
14
|
+
autocapitalize="off"
|
|
15
|
+
spellcheck="false"
|
|
16
|
+
data-search-input
|
|
17
|
+
>
|
|
18
|
+
<button type="button" class="search-modal-close" data-search-close aria-label="Close search">
|
|
19
|
+
<span class="search-modal-close-text">esc</span>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div class="search-modal-body" data-search-body hidden>
|
|
24
|
+
<div class="search-modal-loading" data-search-loading hidden>
|
|
25
|
+
<div class="search-modal-spinner"></div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="search-modal-empty" data-search-empty hidden>
|
|
29
|
+
<svg class="search-empty-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor">
|
|
30
|
+
<path d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path>
|
|
31
|
+
</svg>
|
|
32
|
+
<span class="search-empty-title">No results found</span>
|
|
33
|
+
<span class="search-empty-hint">Try different keywords or check your spelling</span>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<ul class="search-modal-results" role="listbox" data-search-results hidden></ul>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div class="search-modal-footer">
|
|
40
|
+
<span class="search-modal-hint"><kbd>Enter</kbd> select</span>
|
|
41
|
+
<span class="search-modal-hint"><kbd>↑</kbd><kbd>↓</kbd> navigate</span>
|
|
42
|
+
<span class="search-modal-hint"><kbd>Esc</kbd> close</span>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<button
|
|
2
|
+
type="button"
|
|
3
|
+
class="search-trigger"
|
|
4
|
+
aria-label="Search documentation"
|
|
5
|
+
aria-haspopup="dialog"
|
|
6
|
+
data-search-trigger
|
|
7
|
+
>
|
|
8
|
+
<span class="search-trigger-icon" aria-hidden="true">
|
|
9
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor">
|
|
10
|
+
<path d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path>
|
|
11
|
+
</svg>
|
|
12
|
+
</span>
|
|
13
|
+
<span class="search-trigger-text">Search...</span>
|
|
14
|
+
<kbd class="search-trigger-shortcut" data-search-shortcut>
|
|
15
|
+
<span class="search-trigger-shortcut-icon" aria-hidden="true">
|
|
16
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor">
|
|
17
|
+
<path d="M180,144H160V112h20a36,36,0,1,0-36-36V96H112V76a36,36,0,1,0-36,36H96v32H76a36,36,0,1,0,36,36V160h32v20a36,36,0,1,0,36-36ZM160,76a20,20,0,1,1,20,20H160ZM56,76a20,20,0,0,1,40,0V96H76A20,20,0,0,1,56,76ZM96,180a20,20,0,1,1-20-20H96Zm16-68h32v32H112Zm68,88a20,20,0,0,1-20-20V160h20a20,20,0,0,1,0,40Z"></path>
|
|
18
|
+
</svg>
|
|
19
|
+
</span>
|
|
20
|
+
<span class="search-trigger-shortcut-text">K</span>
|
|
21
|
+
</kbd>
|
|
22
|
+
</button>
|
|
@@ -6,7 +6,8 @@ module Docyard
|
|
|
6
6
|
def self.normalize(path)
|
|
7
7
|
return "/" if path.nil? || path.empty?
|
|
8
8
|
|
|
9
|
-
normalized = path.delete_suffix("
|
|
9
|
+
normalized = path.delete_suffix("/")
|
|
10
|
+
.delete_suffix(".md")
|
|
10
11
|
.delete_suffix("/index")
|
|
11
12
|
|
|
12
13
|
normalized = "" if normalized == "index"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Docyard
|
|
4
|
+
module Utils
|
|
5
|
+
module UrlHelpers
|
|
6
|
+
def normalize_base_url(url)
|
|
7
|
+
return "/" if url.nil? || url.empty?
|
|
8
|
+
|
|
9
|
+
url = "/#{url}" unless url.start_with?("/")
|
|
10
|
+
url.end_with?("/") ? url : "#{url}/"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def link_path(path)
|
|
14
|
+
return path if path.nil? || path.start_with?("http://", "https://")
|
|
15
|
+
|
|
16
|
+
"#{base_url.chomp('/')}#{path}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/docyard/version.rb
CHANGED
data/lib/docyard.rb
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Core modules
|
|
4
3
|
require_relative "docyard/version"
|
|
5
|
-
require_relative "docyard/constants"
|
|
6
|
-
require_relative "docyard/errors"
|
|
7
|
-
require_relative "docyard/logging"
|
|
4
|
+
require_relative "docyard/config/constants"
|
|
5
|
+
require_relative "docyard/utils/errors"
|
|
6
|
+
require_relative "docyard/utils/logging"
|
|
8
7
|
|
|
9
|
-
# Utilities
|
|
10
8
|
require_relative "docyard/utils/text_formatter"
|
|
11
9
|
require_relative "docyard/utils/path_resolver"
|
|
10
|
+
require_relative "docyard/utils/url_helpers"
|
|
11
|
+
require_relative "docyard/utils/html_helpers"
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
require_relative "docyard/
|
|
15
|
-
require_relative "docyard/
|
|
13
|
+
require_relative "docyard/server/resolution_result"
|
|
14
|
+
require_relative "docyard/server/router"
|
|
15
|
+
require_relative "docyard/server/asset_handler"
|
|
16
|
+
require_relative "docyard/server/dev_server"
|
|
17
|
+
require_relative "docyard/server/preview_server"
|
|
18
|
+
|
|
19
|
+
require_relative "docyard/rendering/markdown"
|
|
20
|
+
require_relative "docyard/rendering/renderer"
|
|
21
|
+
|
|
22
|
+
require_relative "docyard/navigation/sidebar_builder"
|
|
23
|
+
require_relative "docyard/navigation/prev_next_builder"
|
|
24
|
+
|
|
25
|
+
require_relative "docyard/config/branding_resolver"
|
|
16
26
|
|
|
17
|
-
# Application components
|
|
18
|
-
require_relative "docyard/markdown"
|
|
19
|
-
require_relative "docyard/renderer"
|
|
20
|
-
require_relative "docyard/asset_handler"
|
|
21
27
|
require_relative "docyard/initializer"
|
|
22
|
-
require_relative "docyard/server"
|
|
23
28
|
require_relative "docyard/cli"
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
require_relative "docyard/search/pagefind_support"
|
|
31
|
+
require_relative "docyard/search/dev_indexer"
|
|
32
|
+
require_relative "docyard/search/build_indexer"
|
|
33
|
+
|
|
26
34
|
require_relative "docyard/builder"
|
|
27
35
|
require_relative "docyard/build/static_generator"
|
|
28
36
|
require_relative "docyard/build/asset_bundler"
|
|
29
37
|
require_relative "docyard/build/file_copier"
|
|
30
38
|
require_relative "docyard/build/sitemap_generator"
|
|
31
|
-
require_relative "docyard/preview_server"
|
|
32
39
|
|
|
33
40
|
module Docyard
|
|
34
41
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docyard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sanif Himani
|
|
@@ -183,62 +183,65 @@ files:
|
|
|
183
183
|
- README.md
|
|
184
184
|
- Rakefile
|
|
185
185
|
- lib/docyard.rb
|
|
186
|
-
- lib/docyard/asset_handler.rb
|
|
187
186
|
- lib/docyard/build/asset_bundler.rb
|
|
188
187
|
- lib/docyard/build/file_copier.rb
|
|
189
188
|
- lib/docyard/build/sitemap_generator.rb
|
|
190
189
|
- lib/docyard/build/static_generator.rb
|
|
191
190
|
- lib/docyard/builder.rb
|
|
192
191
|
- lib/docyard/cli.rb
|
|
192
|
+
- lib/docyard/components/aliases.rb
|
|
193
193
|
- lib/docyard/components/base_processor.rb
|
|
194
|
-
- lib/docyard/components/callout_processor.rb
|
|
195
|
-
- lib/docyard/components/code_block_diff_preprocessor.rb
|
|
196
|
-
- lib/docyard/components/
|
|
197
|
-
- lib/docyard/components/
|
|
198
|
-
- lib/docyard/components/
|
|
199
|
-
- lib/docyard/components/
|
|
200
|
-
- lib/docyard/components/
|
|
201
|
-
- lib/docyard/components/
|
|
202
|
-
- lib/docyard/components/
|
|
203
|
-
- lib/docyard/components/
|
|
204
|
-
- lib/docyard/components/
|
|
205
|
-
- lib/docyard/components/code_snippet_import_preprocessor.rb
|
|
206
|
-
- lib/docyard/components/heading_anchor_processor.rb
|
|
207
|
-
- lib/docyard/components/icon_detector.rb
|
|
208
|
-
- lib/docyard/components/icon_processor.rb
|
|
194
|
+
- lib/docyard/components/processors/callout_processor.rb
|
|
195
|
+
- lib/docyard/components/processors/code_block_diff_preprocessor.rb
|
|
196
|
+
- lib/docyard/components/processors/code_block_focus_preprocessor.rb
|
|
197
|
+
- lib/docyard/components/processors/code_block_options_preprocessor.rb
|
|
198
|
+
- lib/docyard/components/processors/code_block_processor.rb
|
|
199
|
+
- lib/docyard/components/processors/code_snippet_import_preprocessor.rb
|
|
200
|
+
- lib/docyard/components/processors/heading_anchor_processor.rb
|
|
201
|
+
- lib/docyard/components/processors/icon_processor.rb
|
|
202
|
+
- lib/docyard/components/processors/table_of_contents_processor.rb
|
|
203
|
+
- lib/docyard/components/processors/table_wrapper_processor.rb
|
|
204
|
+
- lib/docyard/components/processors/tabs_processor.rb
|
|
209
205
|
- lib/docyard/components/registry.rb
|
|
210
|
-
- lib/docyard/components/
|
|
211
|
-
- lib/docyard/components/
|
|
212
|
-
- lib/docyard/components/
|
|
213
|
-
- lib/docyard/components/
|
|
214
|
-
- lib/docyard/components/
|
|
206
|
+
- lib/docyard/components/support/code_block/feature_extractor.rb
|
|
207
|
+
- lib/docyard/components/support/code_block/icon_detector.rb
|
|
208
|
+
- lib/docyard/components/support/code_block/line_parser.rb
|
|
209
|
+
- lib/docyard/components/support/code_block/line_wrapper.rb
|
|
210
|
+
- lib/docyard/components/support/code_block/patterns.rb
|
|
211
|
+
- lib/docyard/components/support/code_detector.rb
|
|
212
|
+
- lib/docyard/components/support/tabs/icon_detector.rb
|
|
213
|
+
- lib/docyard/components/support/tabs/parser.rb
|
|
214
|
+
- lib/docyard/components/support/tabs/range_finder.rb
|
|
215
215
|
- lib/docyard/config.rb
|
|
216
|
+
- lib/docyard/config/branding_resolver.rb
|
|
217
|
+
- lib/docyard/config/constants.rb
|
|
216
218
|
- lib/docyard/config/validator.rb
|
|
217
|
-
- lib/docyard/constants.rb
|
|
218
|
-
- lib/docyard/errors.rb
|
|
219
|
-
- lib/docyard/file_watcher.rb
|
|
220
|
-
- lib/docyard/icons.rb
|
|
221
|
-
- lib/docyard/icons/LICENSE.phosphor
|
|
222
|
-
- lib/docyard/icons/file_types.rb
|
|
223
|
-
- lib/docyard/icons/phosphor.rb
|
|
224
219
|
- lib/docyard/initializer.rb
|
|
225
|
-
- lib/docyard/
|
|
226
|
-
- lib/docyard/
|
|
227
|
-
- lib/docyard/
|
|
228
|
-
- lib/docyard/
|
|
229
|
-
- lib/docyard/
|
|
230
|
-
- lib/docyard/
|
|
231
|
-
- lib/docyard/
|
|
232
|
-
- lib/docyard/
|
|
233
|
-
- lib/docyard/
|
|
234
|
-
- lib/docyard/
|
|
235
|
-
- lib/docyard/
|
|
236
|
-
- lib/docyard/
|
|
237
|
-
- lib/docyard/
|
|
238
|
-
- lib/docyard/
|
|
239
|
-
- lib/docyard/
|
|
240
|
-
- lib/docyard/
|
|
241
|
-
- lib/docyard/
|
|
220
|
+
- lib/docyard/navigation/prev_next_builder.rb
|
|
221
|
+
- lib/docyard/navigation/sidebar/config_parser.rb
|
|
222
|
+
- lib/docyard/navigation/sidebar/file_system_scanner.rb
|
|
223
|
+
- lib/docyard/navigation/sidebar/item.rb
|
|
224
|
+
- lib/docyard/navigation/sidebar/renderer.rb
|
|
225
|
+
- lib/docyard/navigation/sidebar/title_extractor.rb
|
|
226
|
+
- lib/docyard/navigation/sidebar/tree_builder.rb
|
|
227
|
+
- lib/docyard/navigation/sidebar_builder.rb
|
|
228
|
+
- lib/docyard/rendering/icons.rb
|
|
229
|
+
- lib/docyard/rendering/icons/LICENSE.phosphor
|
|
230
|
+
- lib/docyard/rendering/icons/file_types.rb
|
|
231
|
+
- lib/docyard/rendering/icons/phosphor.rb
|
|
232
|
+
- lib/docyard/rendering/language_mapping.rb
|
|
233
|
+
- lib/docyard/rendering/markdown.rb
|
|
234
|
+
- lib/docyard/rendering/renderer.rb
|
|
235
|
+
- lib/docyard/search/build_indexer.rb
|
|
236
|
+
- lib/docyard/search/dev_indexer.rb
|
|
237
|
+
- lib/docyard/search/pagefind_support.rb
|
|
238
|
+
- lib/docyard/server/asset_handler.rb
|
|
239
|
+
- lib/docyard/server/dev_server.rb
|
|
240
|
+
- lib/docyard/server/file_watcher.rb
|
|
241
|
+
- lib/docyard/server/preview_server.rb
|
|
242
|
+
- lib/docyard/server/rack_application.rb
|
|
243
|
+
- lib/docyard/server/resolution_result.rb
|
|
244
|
+
- lib/docyard/server/router.rb
|
|
242
245
|
- lib/docyard/templates/assets/css/code.css
|
|
243
246
|
- lib/docyard/templates/assets/css/components/callout.css
|
|
244
247
|
- lib/docyard/templates/assets/css/components/code-block.css
|
|
@@ -247,6 +250,7 @@ files:
|
|
|
247
250
|
- lib/docyard/templates/assets/css/components/logo.css
|
|
248
251
|
- lib/docyard/templates/assets/css/components/navigation.css
|
|
249
252
|
- lib/docyard/templates/assets/css/components/prev-next.css
|
|
253
|
+
- lib/docyard/templates/assets/css/components/search.css
|
|
250
254
|
- lib/docyard/templates/assets/css/components/table-of-contents.css
|
|
251
255
|
- lib/docyard/templates/assets/css/components/tabs.css
|
|
252
256
|
- lib/docyard/templates/assets/css/components/theme-toggle.css
|
|
@@ -260,6 +264,7 @@ files:
|
|
|
260
264
|
- lib/docyard/templates/assets/js/components/code-block.js
|
|
261
265
|
- lib/docyard/templates/assets/js/components/heading-anchor.js
|
|
262
266
|
- lib/docyard/templates/assets/js/components/navigation.js
|
|
267
|
+
- lib/docyard/templates/assets/js/components/search.js
|
|
263
268
|
- lib/docyard/templates/assets/js/components/table-of-contents.js
|
|
264
269
|
- lib/docyard/templates/assets/js/components/tabs.js
|
|
265
270
|
- lib/docyard/templates/assets/js/reload.js
|
|
@@ -285,14 +290,20 @@ files:
|
|
|
285
290
|
- lib/docyard/templates/partials/_nav_list.html.erb
|
|
286
291
|
- lib/docyard/templates/partials/_nav_section.html.erb
|
|
287
292
|
- lib/docyard/templates/partials/_prev_next.html.erb
|
|
293
|
+
- lib/docyard/templates/partials/_search_modal.html.erb
|
|
294
|
+
- lib/docyard/templates/partials/_search_trigger.html.erb
|
|
288
295
|
- lib/docyard/templates/partials/_sidebar.html.erb
|
|
289
296
|
- lib/docyard/templates/partials/_sidebar_footer.html.erb
|
|
290
297
|
- lib/docyard/templates/partials/_table_of_contents.html.erb
|
|
291
298
|
- lib/docyard/templates/partials/_table_of_contents_toggle.html.erb
|
|
292
299
|
- lib/docyard/templates/partials/_tabs.html.erb
|
|
293
300
|
- lib/docyard/templates/partials/_theme_toggle.html.erb
|
|
301
|
+
- lib/docyard/utils/errors.rb
|
|
302
|
+
- lib/docyard/utils/html_helpers.rb
|
|
303
|
+
- lib/docyard/utils/logging.rb
|
|
294
304
|
- lib/docyard/utils/path_resolver.rb
|
|
295
305
|
- lib/docyard/utils/text_formatter.rb
|
|
306
|
+
- lib/docyard/utils/url_helpers.rb
|
|
296
307
|
- lib/docyard/version.rb
|
|
297
308
|
- sig/docyard.rbs
|
|
298
309
|
homepage: https://github.com/sanifhimani/docyard
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "../icons"
|
|
4
|
-
require_relative "../renderer"
|
|
5
|
-
require_relative "base_processor"
|
|
6
|
-
require "kramdown"
|
|
7
|
-
require "kramdown-parser-gfm"
|
|
8
|
-
|
|
9
|
-
module Docyard
|
|
10
|
-
module Components
|
|
11
|
-
class CalloutProcessor < BaseProcessor
|
|
12
|
-
self.priority = 10
|
|
13
|
-
|
|
14
|
-
CALLOUT_TYPES = {
|
|
15
|
-
"note" => { title: "Note", icon: "info", color: "note" },
|
|
16
|
-
"tip" => { title: "Tip", icon: "lightbulb", color: "tip" },
|
|
17
|
-
"important" => { title: "Important", icon: "warning-circle", color: "important" },
|
|
18
|
-
"warning" => { title: "Warning", icon: "warning", color: "warning" },
|
|
19
|
-
"danger" => { title: "Danger", icon: "siren", color: "danger" }
|
|
20
|
-
}.freeze
|
|
21
|
-
|
|
22
|
-
GITHUB_ALERT_TYPES = {
|
|
23
|
-
"NOTE" => "note",
|
|
24
|
-
"TIP" => "tip",
|
|
25
|
-
"IMPORTANT" => "important",
|
|
26
|
-
"WARNING" => "warning",
|
|
27
|
-
"CAUTION" => "danger"
|
|
28
|
-
}.freeze
|
|
29
|
-
|
|
30
|
-
def preprocess(markdown)
|
|
31
|
-
process_container_syntax(markdown)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def postprocess(html)
|
|
35
|
-
process_github_alerts(html)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def process_container_syntax(markdown)
|
|
41
|
-
markdown.gsub(/^:::[ \t]*(\w+)(?:[ \t]+([^\n]+?))?[ \t]*\n(.*?)^:::[ \t]*$/m) do
|
|
42
|
-
process_callout_match(Regexp.last_match(0), Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def process_callout_match(original_match, type_raw, custom_title, content_markdown)
|
|
47
|
-
type = type_raw.downcase
|
|
48
|
-
return original_match unless CALLOUT_TYPES.key?(type)
|
|
49
|
-
|
|
50
|
-
config = CALLOUT_TYPES[type]
|
|
51
|
-
title = determine_title(custom_title, config[:title])
|
|
52
|
-
content_html = render_markdown_content(content_markdown.strip)
|
|
53
|
-
|
|
54
|
-
wrap_in_nomarkdown(render_callout_html(type, title, content_html, config[:icon]))
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def determine_title(custom_title, default_title)
|
|
58
|
-
title = custom_title&.strip
|
|
59
|
-
title.nil? || title.empty? ? default_title : title
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def render_markdown_content(content_markdown)
|
|
63
|
-
return "" if content_markdown.empty?
|
|
64
|
-
|
|
65
|
-
Kramdown::Document.new(
|
|
66
|
-
content_markdown,
|
|
67
|
-
input: "GFM",
|
|
68
|
-
hard_wrap: false,
|
|
69
|
-
syntax_highlighter: "rouge"
|
|
70
|
-
).to_html
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def wrap_in_nomarkdown(html)
|
|
74
|
-
"{::nomarkdown}\n#{html}\n{:/nomarkdown}"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def process_github_alerts(html)
|
|
78
|
-
github_alert_regex = %r{
|
|
79
|
-
<blockquote>\s*
|
|
80
|
-
<p>\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*
|
|
81
|
-
(?:<br\s*/>)?\s*
|
|
82
|
-
(.*?)</p>
|
|
83
|
-
(.*?)
|
|
84
|
-
</blockquote>
|
|
85
|
-
}mx
|
|
86
|
-
|
|
87
|
-
html.gsub(github_alert_regex) do
|
|
88
|
-
process_github_alert_match(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def process_github_alert_match(alert_type, first_para, rest_content)
|
|
93
|
-
type = GITHUB_ALERT_TYPES[alert_type]
|
|
94
|
-
config = CALLOUT_TYPES[type]
|
|
95
|
-
content_html = combine_alert_content(first_para.strip, rest_content.strip)
|
|
96
|
-
|
|
97
|
-
render_callout_html(type, config[:title], content_html, config[:icon])
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def combine_alert_content(first_para, rest_content)
|
|
101
|
-
return "<p>#{first_para}</p>" if rest_content.empty?
|
|
102
|
-
|
|
103
|
-
"<p>#{first_para}</p>#{rest_content}"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def render_callout_html(type, title, content_html, icon_name)
|
|
107
|
-
icon_svg = Icons.render(icon_name, "duotone") || ""
|
|
108
|
-
renderer = Renderer.new
|
|
109
|
-
|
|
110
|
-
renderer.render_partial(
|
|
111
|
-
"_callout", {
|
|
112
|
-
type: type,
|
|
113
|
-
title: title,
|
|
114
|
-
content_html: content_html,
|
|
115
|
-
icon_svg: icon_svg
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base_processor"
|
|
4
|
-
require_relative "code_block_patterns"
|
|
5
|
-
|
|
6
|
-
module Docyard
|
|
7
|
-
module Components
|
|
8
|
-
class CodeBlockDiffPreprocessor < BaseProcessor
|
|
9
|
-
include CodeBlockPatterns
|
|
10
|
-
|
|
11
|
-
self.priority = 6
|
|
12
|
-
|
|
13
|
-
CODE_BLOCK_REGEX = /^```(\w*).*?\n(.*?)^```/m
|
|
14
|
-
TABS_BLOCK_REGEX = /^:::[ \t]*tabs[ \t]*\n.*?^:::[ \t]*$/m
|
|
15
|
-
|
|
16
|
-
def preprocess(content)
|
|
17
|
-
context[:code_block_diff_lines] ||= []
|
|
18
|
-
context[:code_block_error_lines] ||= []
|
|
19
|
-
context[:code_block_warning_lines] ||= []
|
|
20
|
-
@block_index = 0
|
|
21
|
-
@tabs_ranges = find_tabs_ranges(content)
|
|
22
|
-
|
|
23
|
-
content.gsub(CODE_BLOCK_REGEX) { |_| process_code_block(Regexp.last_match) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def process_code_block(match)
|
|
29
|
-
return match[0] if inside_tabs?(match.begin(0))
|
|
30
|
-
|
|
31
|
-
result = extract_all_markers(match[2])
|
|
32
|
-
store_extracted_markers(result)
|
|
33
|
-
@block_index += 1
|
|
34
|
-
match[0].sub(match[2], result[:cleaned_content])
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def store_extracted_markers(result)
|
|
38
|
-
context[:code_block_diff_lines][@block_index] = result[:diff_lines]
|
|
39
|
-
context[:code_block_error_lines][@block_index] = result[:error_lines]
|
|
40
|
-
context[:code_block_warning_lines][@block_index] = result[:warning_lines]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def extract_all_markers(code_content)
|
|
44
|
-
diff_info = extract_diff_lines(code_content)
|
|
45
|
-
error_info = extract_error_lines(diff_info[:cleaned_content])
|
|
46
|
-
warning_info = extract_warning_lines(error_info[:cleaned_content])
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
diff_lines: diff_info[:lines],
|
|
50
|
-
error_lines: error_info[:lines],
|
|
51
|
-
warning_lines: warning_info[:lines],
|
|
52
|
-
cleaned_content: warning_info[:cleaned_content]
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def extract_diff_lines(code_content)
|
|
57
|
-
extract_marker_lines(code_content, DIFF_MARKER_PATTERN) do |match|
|
|
58
|
-
diff_type = match.captures.compact.first
|
|
59
|
-
diff_type == "++" ? :addition : :deletion
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def extract_error_lines(code_content)
|
|
64
|
-
extract_marker_lines(code_content, ERROR_MARKER_PATTERN) { true }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def extract_warning_lines(code_content)
|
|
68
|
-
extract_marker_lines(code_content, WARNING_MARKER_PATTERN) { true }
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def extract_marker_lines(code_content, pattern)
|
|
72
|
-
lines = code_content.lines
|
|
73
|
-
marker_lines = {}
|
|
74
|
-
cleaned_lines = []
|
|
75
|
-
|
|
76
|
-
lines.each_with_index do |line, index|
|
|
77
|
-
line_num = index + 1
|
|
78
|
-
|
|
79
|
-
if (match = line.match(pattern))
|
|
80
|
-
marker_lines[line_num] = yield(match)
|
|
81
|
-
cleaned_lines << line.gsub(pattern, "")
|
|
82
|
-
else
|
|
83
|
-
cleaned_lines << line
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
{ lines: marker_lines, cleaned_content: cleaned_lines.join }
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def inside_tabs?(position)
|
|
91
|
-
@tabs_ranges.any? { |range| range.cover?(position) }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def find_tabs_ranges(content)
|
|
95
|
-
ranges = []
|
|
96
|
-
content.scan(TABS_BLOCK_REGEX) do
|
|
97
|
-
match = Regexp.last_match
|
|
98
|
-
ranges << (match.begin(0)...match.end(0))
|
|
99
|
-
end
|
|
100
|
-
ranges
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|