utopia-project 0.43.0 → 0.44.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
- checksums.yaml.gz.sig +0 -0
- data/context/documentation-guidelines.md +3 -3
- data/lib/utopia/project/base.md +1 -1
- data/lib/utopia/project/base.rb +3 -3
- data/lib/utopia/project/document.rb +22 -15
- data/lib/utopia/project/renderer.rb +24 -0
- data/lib/utopia/project/version.rb +1 -1
- data/readme.md +4 -4
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f02594d75aca403abee0bf56e3e2ec4e398a81df172f6c62cf73cdccba11bc5
|
|
4
|
+
data.tar.gz: bc73b831e8e44df2de6759154a24d91d0d228e062e5c790d5956788ebddc5177
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dd75a8af1c68d0b7d4b64856f569d13468e6b3296303bcad6b02f3595709821c88de4387212aad33a629caa2854b8f5e6ebfdebfe1e0b7a17975ba44f846d68
|
|
7
|
+
data.tar.gz: 0e731e759758f27e1d64a721a9e5aa9eb275e76bf7e01e3e4fe027d2baad520c3b3f249a28bd049fb392278e47a3f646322d54488648136fdba389adc4f0b5c0
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -16,7 +16,7 @@ Source code documentation is included adjacent to the code it describes, using s
|
|
|
16
16
|
However, in short:
|
|
17
17
|
|
|
18
18
|
- Documentation is expected to be in markdown format.
|
|
19
|
-
- You may embed links to definitions using
|
|
19
|
+
- You may embed links to definitions using ruby:`MyClass` or ruby:`my_method`.
|
|
20
20
|
- You can use tags:
|
|
21
21
|
- `@parameters name [Type] Description.`
|
|
22
22
|
- `@yields {|argument| ...} If a block is given.`
|
|
@@ -173,7 +173,7 @@ $ bundle add $project
|
|
|
173
173
|
|
|
174
174
|
`$project` has several core concepts:
|
|
175
175
|
|
|
176
|
-
- A
|
|
176
|
+
- A ruby:`MyProject::MyClass` which represents the main entry point for using the project.
|
|
177
177
|
|
|
178
178
|
## Usage
|
|
179
179
|
|
|
@@ -284,7 +284,7 @@ Following `utopia-project` guidelines, each guide should:
|
|
|
284
284
|
2. **Provide user context**: Explain why users would need this feature
|
|
285
285
|
3. **Include practical examples**: Working code samples that demonstrate real scenarios
|
|
286
286
|
4. **Follow consistent structure**: Problem → Use Cases → Implementation → Best Practices
|
|
287
|
-
5. **Cross-reference appropriately**: Use
|
|
287
|
+
5. **Cross-reference appropriately**: Use ruby:`ClassName` for internal references
|
|
288
288
|
6. **Include error handling**: Show how to handle common failure scenarios
|
|
289
289
|
7. **Provide troubleshooting**: Common issues and solutions
|
|
290
290
|
8. **Maintain currency**: Keep examples updated with latest best practices
|
data/lib/utopia/project/base.md
CHANGED
data/lib/utopia/project/base.rb
CHANGED
|
@@ -136,12 +136,12 @@ module Utopia
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
# Format the given text in the context of the given definition and language.
|
|
139
|
-
# See
|
|
139
|
+
# See ruby:`document` for details.
|
|
140
140
|
# @returns [XRB::MarkupString]
|
|
141
141
|
#
|
|
142
142
|
# @example Format text with code links
|
|
143
143
|
# base = Utopia::Project::Base.new
|
|
144
|
-
# base.format("See
|
|
144
|
+
# base.format("See ruby:`Utopia::Project::Base#guides`.") # => XRB::MarkupString
|
|
145
145
|
def format(text, definition = nil, language: definition&.language, **options)
|
|
146
146
|
if document = self.document(text, definition, language: language)
|
|
147
147
|
return XRB::Markup.raw(
|
|
@@ -152,7 +152,7 @@ module Utopia
|
|
|
152
152
|
|
|
153
153
|
# Convert the given markdown text into HTML.
|
|
154
154
|
#
|
|
155
|
-
# Updates
|
|
155
|
+
# Updates language-prefixed inline code (e.g. `ruby:` followed by inline code) into links.
|
|
156
156
|
#
|
|
157
157
|
# @returns [Document]
|
|
158
158
|
#
|
|
@@ -29,7 +29,7 @@ module Utopia
|
|
|
29
29
|
# Parse and resolve the document root.
|
|
30
30
|
# @returns [Markly::Node] The root document node.
|
|
31
31
|
def root
|
|
32
|
-
@root ||= resolve(Markly.parse(@text, extensions: [:table]))
|
|
32
|
+
@root ||= resolve(Markly.parse(@text, flags: Markly::INLINE_CODE_INFO, extensions: [:table]))
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Extract the leading heading as the document title.
|
|
@@ -99,7 +99,12 @@ module Utopia
|
|
|
99
99
|
# @parameter node [Markly::Node] The node to render.
|
|
100
100
|
# @returns [XRB::MarkupString] The rendered HTML markup.
|
|
101
101
|
def to_html(node = self.root, **options)
|
|
102
|
-
renderer = Renderer.new(
|
|
102
|
+
renderer = Renderer.new(
|
|
103
|
+
inline_code_resolver: (@index ? method(:reference_node) : nil),
|
|
104
|
+
ids: true,
|
|
105
|
+
flags: Markly::UNSAFE,
|
|
106
|
+
**options
|
|
107
|
+
)
|
|
103
108
|
XRB::Markup.raw(renderer.render(node))
|
|
104
109
|
end
|
|
105
110
|
|
|
@@ -160,15 +165,9 @@ module Utopia
|
|
|
160
165
|
# @parameter language [String | Nil] The source language name.
|
|
161
166
|
# @returns [Markly::Node] The code node.
|
|
162
167
|
def code_node(content, language = nil)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
167
|
-
else
|
|
168
|
-
node = Markly::Node.new(:code)
|
|
169
|
-
node.string_content = content
|
|
170
|
-
return node
|
|
171
|
-
end
|
|
168
|
+
node = Markly::Node.new(:code)
|
|
169
|
+
node.string_content = content
|
|
170
|
+
node.code_info = language if language
|
|
172
171
|
|
|
173
172
|
return node
|
|
174
173
|
end
|
|
@@ -176,9 +175,17 @@ module Utopia
|
|
|
176
175
|
private
|
|
177
176
|
|
|
178
177
|
# Replace source code references in the given text with HTML anchors.
|
|
179
|
-
#
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
# @parameter content [String] The source code reference.
|
|
179
|
+
# @parameter language [String | Nil] The explicit source language.
|
|
180
|
+
# @returns [Markly::Node] The resolved link or code node.
|
|
181
|
+
def reference_node(content, language: nil)
|
|
182
|
+
reference = if language
|
|
183
|
+
@index.languages.reference_for(language, content)
|
|
184
|
+
else
|
|
185
|
+
@index.languages.parse_reference(content, default_language: @default_language)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if reference
|
|
182
189
|
definition = @index.lookup(reference, relative_to: @definition)
|
|
183
190
|
end
|
|
184
191
|
|
|
@@ -189,7 +196,7 @@ module Utopia
|
|
|
189
196
|
elsif reference
|
|
190
197
|
code_node(reference.identifier, reference.language.name)
|
|
191
198
|
else
|
|
192
|
-
code_node(content)
|
|
199
|
+
code_node(content, language)
|
|
193
200
|
end
|
|
194
201
|
end
|
|
195
202
|
|
|
@@ -10,6 +10,15 @@ module Utopia
|
|
|
10
10
|
module Project
|
|
11
11
|
# Renders project Markdown with support for Mermaid code blocks.
|
|
12
12
|
class Renderer < Markly::Renderer::HTML
|
|
13
|
+
# Initialize the project renderer.
|
|
14
|
+
# @parameter inline_code_resolver [Proc | Nil] Resolves language-prefixed inline code into a replacement node.
|
|
15
|
+
def initialize(inline_code_resolver: nil, **options)
|
|
16
|
+
@inline_code_resolver = inline_code_resolver
|
|
17
|
+
@resolving_inline_code = false
|
|
18
|
+
|
|
19
|
+
super(**options)
|
|
20
|
+
end
|
|
21
|
+
|
|
13
22
|
# Render a heading and expose its title to Pagefind for sub-results.
|
|
14
23
|
# @parameter node [Markly::Node] The heading node.
|
|
15
24
|
def header(node)
|
|
@@ -45,6 +54,21 @@ module Utopia
|
|
|
45
54
|
super
|
|
46
55
|
end
|
|
47
56
|
end
|
|
57
|
+
|
|
58
|
+
# Render inline code, resolving language-prefixed references when possible.
|
|
59
|
+
# @parameter node [Markly::Node] The inline code node.
|
|
60
|
+
def code(node)
|
|
61
|
+
if @inline_code_resolver && !@resolving_inline_code && (language = node.code_language)
|
|
62
|
+
begin
|
|
63
|
+
@resolving_inline_code = true
|
|
64
|
+
out(@inline_code_resolver.call(node.string_content, language: language))
|
|
65
|
+
ensure
|
|
66
|
+
@resolving_inline_code = false
|
|
67
|
+
end
|
|
68
|
+
else
|
|
69
|
+
super
|
|
70
|
+
end
|
|
71
|
+
end
|
|
48
72
|
end
|
|
49
73
|
end
|
|
50
74
|
end
|
data/readme.md
CHANGED
|
@@ -33,6 +33,10 @@ Please see the [project documentation](https://socketry.github.io/utopia-project
|
|
|
33
33
|
|
|
34
34
|
Please see the [project releases](https://socketry.github.io/utopia-project/releases/index) for all releases.
|
|
35
35
|
|
|
36
|
+
### v0.44.0
|
|
37
|
+
|
|
38
|
+
- Add support for language-prefixed inline code references such as ruby:`Object.new`.
|
|
39
|
+
|
|
36
40
|
### v0.41.0
|
|
37
41
|
|
|
38
42
|
- Don't render empty signature block when there are only examples.
|
|
@@ -72,10 +76,6 @@ Please see the [project releases](https://socketry.github.io/utopia-project/rele
|
|
|
72
76
|
|
|
73
77
|
- Fix presentation of release notes on releases page.
|
|
74
78
|
|
|
75
|
-
### v0.31.0
|
|
76
|
-
|
|
77
|
-
- Support brief release notes in `releases.md` document.
|
|
78
|
-
|
|
79
79
|
## See Also
|
|
80
80
|
|
|
81
81
|
- [Utopia](https://github.com/socketry/utopia) — The website framework which powers this web application.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utopia-project
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.44.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -75,14 +75,14 @@ dependencies:
|
|
|
75
75
|
requirements:
|
|
76
76
|
- - "~>"
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version: '0.
|
|
78
|
+
version: '0.17'
|
|
79
79
|
type: :runtime
|
|
80
80
|
prerelease: false
|
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
|
82
82
|
requirements:
|
|
83
83
|
- - "~>"
|
|
84
84
|
- !ruby/object:Gem::Version
|
|
85
|
-
version: '0.
|
|
85
|
+
version: '0.17'
|
|
86
86
|
- !ruby/object:Gem::Dependency
|
|
87
87
|
name: thread-local
|
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
|
Binary file
|