wxruby3-mdap 1.0.0.pre.rc.1
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 +7 -0
- data/.yardopts +20 -0
- data/Apache2.0-LICENSE +202 -0
- data/CC01.0-LICENSE.md +30 -0
- data/CCBY4.0-LICENSE +396 -0
- data/CREDITS.md +15 -0
- data/LICENSE +21 -0
- data/README.md +95 -0
- data/assets/logo.svg +170 -0
- data/lib/wx/mdap/art.rb +480 -0
- data/lib/wx/mdap/provider.rb +248 -0
- data/lib/wx/mdap/version.rb +12 -0
- data/lib/wx/mdap.rb +10 -0
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +91 -0
- data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
- data/rakelib/yard/templates/default/fulldoc/html/setup.rb +38 -0
- data/rakelib/yard/templates/default/layout/html/setup.rb +5 -0
- data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
- data/rakelib/yard/templates/default/tags/setup.rb +16 -0
- data/rakelib/yard/yard/relative_markdown_links/version.rb +8 -0
- data/rakelib/yard/yard/relative_markdown_links.rb +49 -0
- data/rakelib/yard/yard-custom-templates.rb +5 -0
- data/rakelib/yard/yard-relative_markdown_links.rb +4 -0
- metadata +87 -0
@@ -0,0 +1,248 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
|
6
|
+
module Wx
|
7
|
+
|
8
|
+
module MDAP
|
9
|
+
|
10
|
+
# Material Design art provider class.
|
11
|
+
#
|
12
|
+
# This derived {https://mcorino.github.io/wxRuby3/Wx/ArtProvider.html Wx::ArtProvider} class implements all
|
13
|
+
# required overrides to support the full functionality of `Wx::ArtProvider` to access a set of Material Design
|
14
|
+
# SVG Art consisting of nearly 9000 images distributed over 11 lists from Fluent UI, Font Awesome, Material Design
|
15
|
+
# and Simple Icons collections (see the {file:README.md} for more information).<br>
|
16
|
+
#
|
17
|
+
# ## Identifying art resources
|
18
|
+
#
|
19
|
+
# Each list from these collections has been mapped to a distinct Art Client id and for each image a distinct
|
20
|
+
# Art id has been defined.<br>
|
21
|
+
# See {Wx::MDAP here} for all defined Art (Client) id constants.<br>
|
22
|
+
#
|
23
|
+
# ## Art overviews
|
24
|
+
#
|
25
|
+
# Overviews of the available icons for the various Art Client id/Art id combinations can be found at the
|
26
|
+
# following locations:
|
27
|
+
#
|
28
|
+
# - {file:FLUENT_UI-Art.md Fluent UI art}
|
29
|
+
# - {file:FONT_AWESOME-Art.md Font Awesome art}
|
30
|
+
# - {file:MATERIAL_DESIGN-Art.md Material Design art}
|
31
|
+
# - {file:SIMPLE_ICONS-Art.md Simple Icons art}
|
32
|
+
#
|
33
|
+
# ## Extensions
|
34
|
+
#
|
35
|
+
# The MaterialDesignArtProvider class provides a number of extensions to customize the default colour and default
|
36
|
+
# size for MaterialDesignArtProvider returned images as well a mapping scheme for standard wxRuby3 Art (Client) ids
|
37
|
+
# to MaterialDesignArtProvider specific ids.
|
38
|
+
#
|
39
|
+
# ### Managing Art colour
|
40
|
+
#
|
41
|
+
# By default MaterialDesignArtProvider will return images in the colour as defined in the original SVG which is
|
42
|
+
# usually BLACK.
|
43
|
+
# This can be overridden by using either of 2 methods; {.use_art_colour} and/or {.with_art_colour}.
|
44
|
+
#
|
45
|
+
# ### Managing Art size
|
46
|
+
#
|
47
|
+
# When requesting images from MaterialDesignArtProvider with `Wx::DEFAULT_SIZE` by default the size used will be
|
48
|
+
# derived from {https://mcorino.github.io/wxRuby3/Wx/ArtProvider.html#get_native_size_hint-class_method Wx::ArtProvider.get_native_size_hint}.
|
49
|
+
# In case this returns `Wx::DEFAULT_SIZE` itself the default will be `Wx::Size.new(24,24)`.
|
50
|
+
# This can be overridden by using {.set_default_size}. Use {.get_default_size} to see what the current default size
|
51
|
+
# will be.
|
52
|
+
#
|
53
|
+
# ### Mapping standard wxRuby3 Art ids
|
54
|
+
#
|
55
|
+
# MaterialDesignArtProvider implements a **fixed** mapping scheme for mapping standard wxRuby3 Art ids (like
|
56
|
+
# `Wx::ART_ERROR`, `Wx::FILE_SAVE`, `Wx::ART_FOLDER` etc.) to MaterialDesignArtProvider Art ids (defined in {Wx::MDAP}).
|
57
|
+
# An overview of this mapping scheme can be found {file:STANDARD-Art-Mappings.md here}.<br>
|
58
|
+
# In addition to that MaterialDesignArtProvider implements a customizable mapping scheme for mapping standard
|
59
|
+
# wxRuby3 Art Client ids (like `Wx::ART_MENU`, `Wx::ART_TOOLBAR`, `Wx::ART_OTHER` etc.) to MaterialDesignArtProvider
|
60
|
+
# Art Client ids (defined in {Wx::MDAP}).
|
61
|
+
# By default all standard Art Client ids are mapped to {Wx::MDAP::ART_FLUENT_UI_REGULAR}. This can be overridden by
|
62
|
+
# using {.map_std_client_id}.
|
63
|
+
#
|
64
|
+
class MaterialDesignArtProvider < Wx::ArtProvider
|
65
|
+
|
66
|
+
class << self
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
# Returns the current default Material Design Art colour
|
71
|
+
# (default `nil` meaning to use the SVG images 'as-is')
|
72
|
+
def art_colour
|
73
|
+
@art_colour
|
74
|
+
end
|
75
|
+
|
76
|
+
# (Re)Sets the default Material Design Art colour
|
77
|
+
def set_art_colour(colour)
|
78
|
+
@art_colour = if colour.is_a?(Wx::Colour)
|
79
|
+
colour
|
80
|
+
else
|
81
|
+
colour ? Wx::Colour.new(colour) : nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the registry of the default sizes for each Material Design Art client
|
86
|
+
def default_sizes
|
87
|
+
@def_sizes ||= {}
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns a list of the standard wxRuby3 Art Client ids
|
91
|
+
def std_client_ids
|
92
|
+
@std_client_ids ||= [
|
93
|
+
Wx::ART_TOOLBAR,
|
94
|
+
Wx::ART_MENU,
|
95
|
+
Wx::ART_BUTTON,
|
96
|
+
Wx::ART_FRAME_ICON,
|
97
|
+
Wx::ART_CMN_DIALOG,
|
98
|
+
Wx::ART_HELP_BROWSER,
|
99
|
+
Wx::ART_MESSAGE_BOX,
|
100
|
+
Wx::ART_OTHER]
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns the registry mapping standard wxRuby3 Art Client ids to Material Design Art Client ids.
|
104
|
+
# If no mapping specified the default mapping will be {Wx::MDAP::ART_FLUENT_UI_REGULAR}
|
105
|
+
def std_client_id_map
|
106
|
+
@std_client_id_map ||= ::Hash.new(Wx::MDAP::ART_FLUENT_UI_REGULAR)
|
107
|
+
end
|
108
|
+
|
109
|
+
public
|
110
|
+
|
111
|
+
# Sets the active colour to use for created MaterialDesign art.
|
112
|
+
# By default the colour is `nil` (which is equivalent to :BLACK).
|
113
|
+
# @param [Wx::Colour,String,Symbol,nil] colour
|
114
|
+
def use_art_colour(colour)
|
115
|
+
set_art_colour(colour)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Sets the active colour to use for created MaterialDesign art in the scope of the given block.
|
119
|
+
# After the block returns the colour is restored to it's setting from before the block.
|
120
|
+
# @param [Wx::Colour,String,Symbol,nil] colour
|
121
|
+
def with_art_colour(colour)
|
122
|
+
prev_colour = art_colour
|
123
|
+
begin
|
124
|
+
set_art_colour(colour)
|
125
|
+
yield if block_given?
|
126
|
+
ensure
|
127
|
+
set_art_colour(prev_colour)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Returns the default art size for the given (standard or Material Design) Art Client id.
|
132
|
+
# By default will derive default from {Wx::ArtProvider.get_native_size_hint}.
|
133
|
+
# @param [String] client Art Client id
|
134
|
+
# @return [Wx::size]
|
135
|
+
def get_default_size(client)
|
136
|
+
raise ArgumentError, "Invalid art client id [#{client}]" unless std_client_ids.include?(client) || MDAP.has_art_client_id?(client)
|
137
|
+
unless default_sizes.has_key?(client)
|
138
|
+
def_sz = Wx::ArtProvider.get_native_size_hint(client)
|
139
|
+
default_sizes[client] = (def_sz == Wx::DEFAULT_SIZE ? Wx::Size.new(24,24) : def_sz)
|
140
|
+
end
|
141
|
+
default_sizes[client]
|
142
|
+
end
|
143
|
+
|
144
|
+
# Sets the default art size for the given (standard or Material Design) Art Client id.
|
145
|
+
# @param [String] client Art Client id
|
146
|
+
# @param [Wx::Size,Array(Integer,Integer)] size
|
147
|
+
def set_default_size(client, size)
|
148
|
+
raise ArgumentError, "Invalid art client id [#{client}]" unless std_client_ids.include?(client) || MDAP.has_art_client_id?(client)
|
149
|
+
default_sizes[client] = size.to_size
|
150
|
+
end
|
151
|
+
|
152
|
+
# Sets the MDAP client id to use when a std wxRuby3 ClientArtId is passed to {MaterialDesignArtProvider}.
|
153
|
+
# By default the alternative id used for any standard id is {Wx::MDAP::ART_FLUENT_UI_REGULAR}.
|
154
|
+
# The `std_client_id` passed should be one of:
|
155
|
+
#
|
156
|
+
# - {Wx::ART_TOOLBAR}
|
157
|
+
# - {Wx::ART_MENU}
|
158
|
+
# - {Wx::ART_BUTTON}
|
159
|
+
# - {Wx::ART_FRAME_ICON}
|
160
|
+
# - {Wx::ART_CMN_DIALOG}
|
161
|
+
# - {Wx::ART_HELP_BROWSER}
|
162
|
+
# - {Wx::ART_MESSAGE_BOX}
|
163
|
+
# - {Wx::ART_OTHER}
|
164
|
+
#
|
165
|
+
# The `md_client_id` passed should be one of:
|
166
|
+
#
|
167
|
+
# - {Wx::MDAP::ART_FLUENT_UI_REGULAR}
|
168
|
+
# - {Wx::MDAP::ART_FLUENT_UI_FILLED}
|
169
|
+
# - {Wx::MDAP::ART_FONT_AWESOME_REGULAR}
|
170
|
+
# - {Wx::MDAP::ART_FONT_AWESOME_SOLID}
|
171
|
+
# - {Wx::MDAP::ART_MATERIAL_DESIGN_FILLED}
|
172
|
+
# - {Wx::MDAP::ART_MATERIAL_DESIGN_OUTLINED}
|
173
|
+
# - {Wx::MDAP::ART_MATERIAL_DESIGN_ROUND}
|
174
|
+
# - {Wx::MDAP::ART_MATERIAL_DESIGN_SHARP}
|
175
|
+
# - {Wx::MDAP::ART_MATERIAL_DESIGN_TWO_TONE}
|
176
|
+
#
|
177
|
+
# @param [String] std_client_id the standard client id to map
|
178
|
+
# @param [String] md_client_id the alternative Material Design client id to use
|
179
|
+
def map_std_client_id(std_client_id, md_client_id)
|
180
|
+
raise ArgumentError, "Invalid standard art client id [#{std_client_id}]" unless std_client_ids.include?(std_client_id)
|
181
|
+
raise ArgumentError, "Invalid Material Design art client id [#{md_client_id}]" unless MDAP.has_art_client_id?(md_client_id)
|
182
|
+
std_client_id_map[std_client_id] = md_client_id
|
183
|
+
end
|
184
|
+
|
185
|
+
# @api private
|
186
|
+
def resolve_client_id(client_id)
|
187
|
+
std_client_ids.include?(client_id) ? std_client_id_map[client_id] : client_id
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
protected
|
193
|
+
|
194
|
+
def create_bitmap(id, client, size)
|
195
|
+
# create bundle and get bitmap from it
|
196
|
+
bundle = create_bitmap_bundle(id, client, size)
|
197
|
+
return Wx::NULL_BITMAP unless bundle.ok?
|
198
|
+
bmp = bundle.get_bitmap(size)
|
199
|
+
bmp.ok? ? bmp : Wx::NULL_BITMAP
|
200
|
+
end
|
201
|
+
|
202
|
+
def create_bitmap_bundle(id, client, size)
|
203
|
+
size = size.to_size # make sure to have a Wx::Size
|
204
|
+
# handle this **before** resolving the client id
|
205
|
+
size = MaterialDesignArtProvider.get_default_size(client) if size == Wx::DEFAULT_SIZE
|
206
|
+
# handle standard wxRuby3 client id mapping (if any)
|
207
|
+
client = MaterialDesignArtProvider.resolve_client_id(client)
|
208
|
+
art_path = MDAP.get_art_for(client, id)
|
209
|
+
return Wx::NULL_BITMAP unless art_path
|
210
|
+
if (art_clr = MaterialDesignArtProvider.__send__(:art_colour))
|
211
|
+
svg_data = change_svg_colour(File.read(art_path), art_clr)
|
212
|
+
Wx::BitmapBundle.from_svg(svg_data, size)
|
213
|
+
else
|
214
|
+
# create bundle
|
215
|
+
Wx::BitmapBundle.from_svg_file(art_path, size)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def create_icon_bundle(id, client)
|
220
|
+
bundle = create_bitmap_bundle(id, client, size = MaterialDesignArtProvider.get_default_size(client))
|
221
|
+
Wx::IconBundle.new(bundle.get_icon(size))
|
222
|
+
end
|
223
|
+
|
224
|
+
private
|
225
|
+
|
226
|
+
# @api private
|
227
|
+
FILL_RE = /fill="#(?:[0-9a-fA-F]{3,4}){1,2}"/
|
228
|
+
# @api private
|
229
|
+
PATH_RE = /<path\s/
|
230
|
+
|
231
|
+
def change_svg_colour(svg_data, colour)
|
232
|
+
# see if we can replace the path colours
|
233
|
+
rc = svg_data.gsub!(FILL_RE, "fill=\"#{colour.get_as_string(Wx::C2S_HTML_SYNTAX)}\"")
|
234
|
+
# if any replaced we're done
|
235
|
+
return svg_data if rc
|
236
|
+
# insert colour to every <path ...>
|
237
|
+
svg_data.gsub!(PATH_RE, "<path fill=\"#{colour.get_as_string(Wx::C2S_HTML_SYNTAX)}\"")
|
238
|
+
svg_data
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
# Import MaterialDesignArtProvider in Wx namespace if possible
|
246
|
+
MaterialDesignArtProvider = MDAP::MaterialDesignArtProvider unless Wx.const_defined?(:MaterialDesignArtProvider)
|
247
|
+
|
248
|
+
end
|
data/lib/wx/mdap.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
div.wxrb-note {
|
3
|
+
background: #f7f7f9;
|
4
|
+
border-left: .6em solid #f3ba6f;
|
5
|
+
border-radius: 3px;
|
6
|
+
margin: 14px;
|
7
|
+
padding-left: 14px;
|
8
|
+
padding-top: 10px;
|
9
|
+
padding-bottom: 10px;
|
10
|
+
}
|
11
|
+
|
12
|
+
div.wxrb-remark {
|
13
|
+
background: #f7f7f9;
|
14
|
+
border-left: .6em solid #f6f4ab;
|
15
|
+
border-radius: 3px;
|
16
|
+
margin: 14px;
|
17
|
+
padding-left: 14px;
|
18
|
+
padding-top: 10px;
|
19
|
+
padding-bottom: 10px;
|
20
|
+
}
|
21
|
+
|
22
|
+
div.wxrb-note p,
|
23
|
+
div.wxrb-remark p {
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
div.wxrb-logo {
|
28
|
+
float: right;
|
29
|
+
padding-top: 12px;
|
30
|
+
}
|
31
|
+
|
32
|
+
div.wxrb-logo img {
|
33
|
+
vertical-align: middle;
|
34
|
+
}
|
35
|
+
|
36
|
+
div.wxrb-logo span.wxrb-name {
|
37
|
+
font-size: large;
|
38
|
+
font-weight: bold;
|
39
|
+
margin-left: 10px;
|
40
|
+
}
|
41
|
+
|
42
|
+
div.wxrb-logo span.wxrb-name a {
|
43
|
+
color: black;
|
44
|
+
}
|
45
|
+
|
46
|
+
div.wxrb-logo span.wxrb-version {
|
47
|
+
font-size: medium;
|
48
|
+
font-weight: normal;
|
49
|
+
margin-left: 10px;
|
50
|
+
}
|
51
|
+
|
52
|
+
div.wxrb-logo table {
|
53
|
+
display: inline;
|
54
|
+
}
|
55
|
+
|
56
|
+
div.wxrb-logo table td {
|
57
|
+
margin: 0;
|
58
|
+
}
|
59
|
+
|
60
|
+
.discussion div.note {
|
61
|
+
background: #f7f7f9;
|
62
|
+
border-left: .6em solid #f3ba6f;
|
63
|
+
margin: 14px;
|
64
|
+
}
|
65
|
+
|
66
|
+
.tags span.wxrb-require {
|
67
|
+
border-radius: 5px;
|
68
|
+
border: 1px solid #E1E1E8;
|
69
|
+
padding: 0px 3px 0px 3px;
|
70
|
+
background: #f3ba6f;
|
71
|
+
font-weight: bold;
|
72
|
+
font-size: 0.9em;
|
73
|
+
}
|
74
|
+
|
75
|
+
#filecontents {
|
76
|
+
margin-right: 340px;
|
77
|
+
}
|
78
|
+
|
79
|
+
#filecontents blockquote {
|
80
|
+
border-left: .5em solid #e0e0e0;
|
81
|
+
margin: 10px;
|
82
|
+
padding-left: 10px;
|
83
|
+
}
|
84
|
+
|
85
|
+
#toc {
|
86
|
+
position: fixed;
|
87
|
+
overflow-y: scroll;
|
88
|
+
overflow-x: hidden;
|
89
|
+
top: 1em;
|
90
|
+
bottom: 0;
|
91
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
+
<meta charset="<%= charset %>" />
|
6
|
+
<% stylesheets_full_list.each do |stylesheet| %>
|
7
|
+
<link rel="stylesheet" href="<%= mtime_url(stylesheet) %>" type="text/css" media="screen" />
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% javascripts_full_list.each do |javascript| %>
|
11
|
+
<script type="text/javascript" charset="utf-8" src="<%= mtime_url(javascript) %>"></script>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<title><%= @list_title %></title>
|
15
|
+
<base id="base_target" target="_parent" />
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
<div id="content">
|
19
|
+
<div class="fixed_header">
|
20
|
+
<%= logo_and_version %>
|
21
|
+
<h1 id="full_list_header"><%= @list_title %></h1>
|
22
|
+
<div id="full_list_nav">
|
23
|
+
<% menu_lists.each do |list| %>
|
24
|
+
<span><a target="_self" href="<%= url_for_list list[:type] %>">
|
25
|
+
<%= list[:title] %>
|
26
|
+
</a></span>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div id="search">Search: <input type="text" /></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<ul id="full_list" class="<%= @list_class || @list_type %>">
|
34
|
+
<%= erb "full_list_#{@list_type}" %>
|
35
|
+
</ul>
|
36
|
+
</div>
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def init
|
4
|
+
# It seems YARD messes things up so that a lot of classes, modules and constants are not properly
|
5
|
+
# registered in their enclosing namespaces.
|
6
|
+
# This hack makes sure that if that is the case we fix that here.
|
7
|
+
all_objects = Registry.all(:class, :constant, :module, :method)
|
8
|
+
all_objects.each do |c|
|
9
|
+
if (ns = c.namespace)
|
10
|
+
unless ns.children.any? { |nsc| nsc.path == c.path }
|
11
|
+
ns.children << c # class/module/constant/method missing from child list of enclosing namespace -> add here
|
12
|
+
end
|
13
|
+
end
|
14
|
+
if (ns = Registry[c.namespace.path])
|
15
|
+
unless ns.children.any? { |nsc| nsc.path == c.path }
|
16
|
+
ns.children << c # class/module/constant/method missing from child list of enclosing namespace -> add here
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def stylesheets_full_list
|
24
|
+
super + %w(css/wxruby3.css)
|
25
|
+
end
|
26
|
+
|
27
|
+
def logo_and_version
|
28
|
+
wxver = Registry['Wx::MDAP::VERSION']
|
29
|
+
<<~__HTML
|
30
|
+
<div class='wxrb-logo'>
|
31
|
+
<img src='art/logo.svg' height='38'/>
|
32
|
+
<table><tbody>
|
33
|
+
<tr><td><span class='wxrb-name'><a href="https://github.com/mcorino/wxRuby3-MaterialDesignArtProvider">wxRuby3 MaterialDesignArtProvider</a></span></td></tr>
|
34
|
+
<tr><td><span class='wxrb-version'>Version: #{::Kernel.eval(wxver.value)}</span></td></tr>
|
35
|
+
</tbody></table>
|
36
|
+
</div>
|
37
|
+
__HTML
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def wxrb_require
|
4
|
+
erb('wxrb_require')
|
5
|
+
end
|
6
|
+
|
7
|
+
def wxruby_requires
|
8
|
+
object.tags(:wxrb_require).inject([]) do |list, tag|
|
9
|
+
tag.text.split(',').each do |feature|
|
10
|
+
list << feature.split('|').collect do |s|
|
11
|
+
s.split('&').collect { |ss| %Q[<span class="wxrb-require">#{ss.strip}</span>] }.join('&')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
list
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "nokogiri"
|
4
|
+
require "uri"
|
5
|
+
require "yard"
|
6
|
+
require_relative 'relative_markdown_links/version'
|
7
|
+
|
8
|
+
module YARD # rubocop:disable Style/Documentation
|
9
|
+
# GitHub and YARD render Markdown files differently. In particular, relative
|
10
|
+
# links between Markdown files that work in GitHub don't work in YARD.
|
11
|
+
# For example, if you have `[hello](FOO.md)` in your README, YARD renders it
|
12
|
+
# as `<a href="FOO.md">hello</a>`, creating a broken link in your docs.
|
13
|
+
#
|
14
|
+
# With this plugin enabled, you'll get `<a href="file.FOO.html">hello</a>`
|
15
|
+
# instead, which correctly links through to the rendered HTML file.
|
16
|
+
module RelativeMarkdownLinks
|
17
|
+
# Resolves relative links from Markdown files.
|
18
|
+
# @param [String] text the HTML fragment in which to resolve links.
|
19
|
+
# @return [String] HTML with relative links to extra files converted to `{file:}` links.
|
20
|
+
def resolve_links(text)
|
21
|
+
html = Nokogiri::HTML.fragment(text)
|
22
|
+
html.css("a[href]").each do |link|
|
23
|
+
begin
|
24
|
+
href = URI(link["href"])
|
25
|
+
rescue
|
26
|
+
return super(text)
|
27
|
+
end
|
28
|
+
|
29
|
+
if href.relative? && options.files
|
30
|
+
fnames = options.files.map(&:filename)
|
31
|
+
if fnames.include?(href.path)
|
32
|
+
link.replace "{file:#{href} #{link.inner_html}}"
|
33
|
+
elsif href.path.end_with?('_md.html') && (fname = fnames.find {|fnm| fnm.end_with?(href.path.sub(/_md.html\Z/, '.md')) })
|
34
|
+
link.replace "{file:#{fname}#{href.fragment ? "##{fragment_to_yard(href.fragment)}" : ''} #{link.inner_html}}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
super(html.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
# this does not work with mixed case labels but is good enough for us
|
42
|
+
def fragment_to_yard(s)
|
43
|
+
s.start_with?('label-') ? s : "label-#{s.gsub('-', '+').capitalize}"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
Templates::Template.extra_includes << RelativeMarkdownLinks
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wxruby3-mdap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.rc.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Corino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: wxruby3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
description: wxRuby3/MDAP is a pure Ruby library providing a custom ArtProvider for
|
28
|
+
using MaterialDesign bitmaps and icons in wxRuby3
|
29
|
+
email: mcorino@m2c-software.nl
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".yardopts"
|
35
|
+
- Apache2.0-LICENSE
|
36
|
+
- CC01.0-LICENSE.md
|
37
|
+
- CCBY4.0-LICENSE
|
38
|
+
- CREDITS.md
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- assets/logo.svg
|
42
|
+
- lib/wx/mdap.rb
|
43
|
+
- lib/wx/mdap/art.rb
|
44
|
+
- lib/wx/mdap/provider.rb
|
45
|
+
- lib/wx/mdap/version.rb
|
46
|
+
- rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css
|
47
|
+
- rakelib/yard/templates/default/fulldoc/html/full_list.erb
|
48
|
+
- rakelib/yard/templates/default/fulldoc/html/setup.rb
|
49
|
+
- rakelib/yard/templates/default/layout/html/setup.rb
|
50
|
+
- rakelib/yard/templates/default/tags/html/wxrb_require.erb
|
51
|
+
- rakelib/yard/templates/default/tags/setup.rb
|
52
|
+
- rakelib/yard/yard-custom-templates.rb
|
53
|
+
- rakelib/yard/yard-relative_markdown_links.rb
|
54
|
+
- rakelib/yard/yard/relative_markdown_links.rb
|
55
|
+
- rakelib/yard/yard/relative_markdown_links/version.rb
|
56
|
+
homepage: https://github.com/mcorino/wxRuby3-MaterialDesignArtProvider
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
bug_tracker_uri: https://github.com/mcorino/wxRuby3-MaterialDesignArtProvider/issues
|
61
|
+
documentation_uri: https://mcorino.github.io/wxRuby3-MaterialDesignArtProvider
|
62
|
+
homepage_uri: https://github.com/mcorino/wxRuby3-MaterialDesignArtProvider
|
63
|
+
github_repo: https://github.com/mcorino/wxRuby3-MaterialDesignArtProvider
|
64
|
+
post_install_message: |2
|
65
|
+
|
66
|
+
wxRuby3/MDAP has been successfully installed.
|
67
|
+
|
68
|
+
Have fun using wxRuby3/MDAP.
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.5'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.5.9
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: wxRuby3 Material Design Art Provider
|
87
|
+
test_files: []
|