utopia-project 0.33.2 → 0.34.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/utopia/project/agent/context.rb +64 -0
- data/bake/utopia/project/readme/update.rb +10 -17
- data/bake/utopia/project.rb +1 -1
- data/context/documentation-formatting.md +67 -0
- data/context/getting-started.md +31 -0
- data/context/github-pages-integration.md +17 -0
- data/context/index.yaml +19 -0
- data/lib/utopia/project/base.rb +15 -1
- data/lib/utopia/project/guide.rb +36 -2
- data/lib/utopia/project/linkify.rb +1 -1
- data/lib/utopia/project/releases_document.rb +1 -1
- data/lib/utopia/project/renderer.rb +1 -1
- data/lib/utopia/project/version.rb +1 -1
- data/lib/utopia/project.rb +1 -1
- data/pages/controller.rb +1 -1
- data/pages/guides/controller.rb +1 -1
- data/pages/releases/controller.rb +1 -1
- data/pages/source/controller.rb +1 -1
- data/readme.md +8 -0
- data/releases.md +8 -0
- data/template/gems.rb +3 -0
- data/template/preload.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +7 -2
- 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: f6d7813076feeeb716ee8b2fed2db46d2d5522d63ef443632687aec95be009f9
|
4
|
+
data.tar.gz: a77ff26f76a698e3d9c90b86270a4ee9fefeecd6108e9bade9c5d603ffe38081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e47b9495910bd0e04b7b3f35f05f06de0e02c827dcb2c08cc8619b81b70e9986b288f4014a3c5fa544b38c97a21e3373287f49881ad67cedd868353b4e91cf
|
7
|
+
data.tar.gz: aad59c90eb1f6556f6332f42afab40bc81031f2414df7fe83231a9bdb71fe2de7f6a4491aec52b53ab225049732c3d7cd0f92722ae4813331bebc29385c2be3c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2025, by Samuel Williams.
|
5
|
+
|
6
|
+
def initialize(...)
|
7
|
+
super
|
8
|
+
|
9
|
+
require "utopia/project"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Update agent context files from the guides.
|
13
|
+
def update
|
14
|
+
project = Utopia::Project::Base.new(context.root)
|
15
|
+
|
16
|
+
FileUtils.mkdir_p self.context_root
|
17
|
+
files = []
|
18
|
+
|
19
|
+
# Sort guides by order, then by name
|
20
|
+
sorted_guides = project.guides.select(&:readme?).sort
|
21
|
+
|
22
|
+
sorted_guides.each do |guide|
|
23
|
+
FileUtils.cp guide.readme_path, self.context_path_for(guide)
|
24
|
+
files << {
|
25
|
+
"path" => guide.name + ".md",
|
26
|
+
"title" => guide.title,
|
27
|
+
"description" => guide.description.to_markdown.chomp,
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
if files.any?
|
32
|
+
# Create index in agent-context compatible format
|
33
|
+
gemspec = project.gemspec
|
34
|
+
index = {
|
35
|
+
"description" => gemspec&.summary,
|
36
|
+
"metadata" => gemspec&.metadata || {},
|
37
|
+
"files" => files,
|
38
|
+
}
|
39
|
+
|
40
|
+
File.open(self.context_index_path, "w") do |file|
|
41
|
+
file.puts "# Automatically generated context index for Utopia::Project guides."
|
42
|
+
file.puts "# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`."
|
43
|
+
YAML.dump(index, file)
|
44
|
+
end
|
45
|
+
|
46
|
+
return index
|
47
|
+
end
|
48
|
+
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def context_root
|
55
|
+
File.join(context.root, "context")
|
56
|
+
end
|
57
|
+
|
58
|
+
def context_path_for(guide)
|
59
|
+
File.join(context_root, guide.name + ".md")
|
60
|
+
end
|
61
|
+
|
62
|
+
def context_index_path
|
63
|
+
File.join(context_root, "index.yaml")
|
64
|
+
end
|
@@ -3,14 +3,17 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2023-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
def initialize(...)
|
7
|
+
super
|
8
|
+
|
9
|
+
require "utopia/project"
|
10
|
+
end
|
8
11
|
|
9
12
|
def update(path: "readme.md", documentation_url: nil)
|
10
13
|
project = Utopia::Project::Base.new(context.root)
|
11
14
|
readme = project.readme_document
|
12
15
|
|
13
|
-
documentation_url ||= public_documentation_url
|
16
|
+
documentation_url ||= public_documentation_url(project)
|
14
17
|
|
15
18
|
readme.replace_section("Usage") do |header|
|
16
19
|
current = header
|
@@ -39,25 +42,15 @@ private
|
|
39
42
|
|
40
43
|
Scope = Struct.new(:documentation_url, :project)
|
41
44
|
|
42
|
-
def gemspec_path
|
43
|
-
Dir.glob("*.gemspec", base: context.root).first
|
44
|
-
end
|
45
|
-
|
46
|
-
def gemspec
|
47
|
-
if gemspec_path = self.gemspec_path
|
48
|
-
@gemspec ||= ::Gem::Specification.load(gemspec_path)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
45
|
# The public documentation URL if it can be determined.
|
53
|
-
def public_documentation_url
|
54
|
-
if metadata = gemspec
|
46
|
+
def public_documentation_url(project)
|
47
|
+
if metadata = project.gemspec&.metadata
|
55
48
|
if documentation_uri = metadata["documentation_uri"]
|
56
49
|
return documentation_uri
|
57
50
|
end
|
58
51
|
end
|
59
52
|
|
60
|
-
return gemspec&.homepage
|
53
|
+
return project.gemspec&.homepage
|
61
54
|
end
|
62
55
|
|
63
56
|
def usage_section(documentation_url, project)
|
@@ -83,7 +76,7 @@ def releases_section(documentation_url, project)
|
|
83
76
|
buffer = String.new
|
84
77
|
|
85
78
|
buffer << "Please see the [project releases](#{documentation_url}releases/index) for all releases.\n"
|
86
|
-
|
79
|
+
|
87
80
|
project.releases.first(10).each do |release|
|
88
81
|
buffer << "\n### #{release.name}\n\n"
|
89
82
|
|
data/bake/utopia/project.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Documentation Formatting
|
2
|
+
|
3
|
+
This guide explains the conventions used by `utopia-project` when generating documentation for your project.
|
4
|
+
|
5
|
+
## Source Code Documentation
|
6
|
+
|
7
|
+
Source code documentation is expected to be in markdown format. This is different from the canonical `RDoc` format used by Ruby. However, using markdown is a good format for standardised documentation across a range of different languages.
|
8
|
+
|
9
|
+
### Tags
|
10
|
+
|
11
|
+
#### `@parameter`
|
12
|
+
|
13
|
+
The `@parameter` tag is used to describe the parameters of a method:
|
14
|
+
|
15
|
+
~~~ ruby
|
16
|
+
# @parameter x [Integer] The x co-ordinate.
|
17
|
+
# @parameter y [Integer] The y co-ordinate.
|
18
|
+
def move(x, y)
|
19
|
+
# ...
|
20
|
+
end
|
21
|
+
~~~
|
22
|
+
|
23
|
+
#### `@returns`
|
24
|
+
|
25
|
+
The `@returns` tag is used to describe the return type of the definition:
|
26
|
+
|
27
|
+
~~~ ruby
|
28
|
+
# @returns [Integer] The result of the computation.
|
29
|
+
def fib(n)
|
30
|
+
# ...
|
31
|
+
end
|
32
|
+
~~~
|
33
|
+
|
34
|
+
### References
|
35
|
+
|
36
|
+
It is possible to insert references in your documentation using curly brackets. In the following example `{Input}` will be expanded relative to the usage, to some symbol named `Input`.
|
37
|
+
|
38
|
+
~~~ ruby
|
39
|
+
# Frobulates the input, see {Input} for more details.
|
40
|
+
def frobulate(input)
|
41
|
+
# ... left to the imagination ...
|
42
|
+
end
|
43
|
+
~~~
|
44
|
+
|
45
|
+
## Examples & Guides
|
46
|
+
|
47
|
+
Examples provide structured information to help users understand your project and are located in the `examples/` directory. One sub-directory per example.
|
48
|
+
|
49
|
+
### `readme.md`
|
50
|
+
|
51
|
+
If an example has a `readme.md` file, it is used as the main source of documentation.
|
52
|
+
|
53
|
+
### Source Files
|
54
|
+
|
55
|
+
All other source files are listed on the example page. Top level comments with trailing code (segments) are used to help guide the user through the example.
|
56
|
+
|
57
|
+
## Diagrams
|
58
|
+
|
59
|
+
You can add diagrams formatted using `mermaid.js`.
|
60
|
+
|
61
|
+
``` mermaid
|
62
|
+
graph LR;
|
63
|
+
A-->B;
|
64
|
+
A-->C;
|
65
|
+
B-->D;
|
66
|
+
C-->D;
|
67
|
+
```
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
This guide explains how to use `utopia-project` for your own project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Firstly, add the gem to your project:
|
8
|
+
|
9
|
+
~~~ bash
|
10
|
+
$ bundle add utopia-project
|
11
|
+
~~~
|
12
|
+
|
13
|
+
## Start Local Server
|
14
|
+
|
15
|
+
Start the local server to preview documentation:
|
16
|
+
|
17
|
+
~~~ bash
|
18
|
+
$ bake utopia:project:serve
|
19
|
+
~~~
|
20
|
+
|
21
|
+
Right now, this server does not reload the code index, so you will need to restart the server to update the code index. This will be fixed in the future.
|
22
|
+
|
23
|
+
## Generate Static Site
|
24
|
+
|
25
|
+
You can generate a static copy of your documentation into the `docs/` folder:
|
26
|
+
|
27
|
+
~~~ bash
|
28
|
+
$ bake utopia:project:static
|
29
|
+
~~~
|
30
|
+
|
31
|
+
You can check the [guide for GitHub Pages](../github-pages-integration/index) which gives more details on how to deploy the static site using GitHub.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# GitHub Pages Integration
|
2
|
+
|
3
|
+
This guide shows you how to use `utopia-project` with GitHub Pages.
|
4
|
+
|
5
|
+
## Static Site Generation
|
6
|
+
|
7
|
+
Once you are happy with your project's documentation, use this command to generate a static site:
|
8
|
+
|
9
|
+
~~~ bash
|
10
|
+
$ bake utopia:project:static
|
11
|
+
~~~
|
12
|
+
|
13
|
+
This will generate a static copy of your documentation into `docs/` which is what is required by GitHub Pages.
|
14
|
+
|
15
|
+
## Enable GitHub Pages
|
16
|
+
|
17
|
+
In your GitHub project settings, you will need to [enable GitHub Pages served from `docs/`](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#choosing-a-publishing-source).
|
data/context/index.yaml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Automatically generated context index for Utopia::Project guides.
|
2
|
+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
|
3
|
+
---
|
4
|
+
description: A project documentation tool based on Utopia.
|
5
|
+
metadata:
|
6
|
+
documentation_uri: https://socketry.github.io/utopia-project/
|
7
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
8
|
+
source_code_uri: https://github.com/socketry/utopia-project/
|
9
|
+
files:
|
10
|
+
- path: getting-started.md
|
11
|
+
title: Getting Started
|
12
|
+
description: This guide explains how to use `utopia-project` for your own project.
|
13
|
+
- path: documentation-formatting.md
|
14
|
+
title: Documentation Formatting
|
15
|
+
description: This guide explains the conventions used by `utopia-project` when generating
|
16
|
+
documentation for your project.
|
17
|
+
- path: github-pages-integration.md
|
18
|
+
title: GitHub Pages Integration
|
19
|
+
description: This guide shows you how to use `utopia-project` with GitHub Pages.
|
data/lib/utopia/project/base.rb
CHANGED
@@ -178,7 +178,7 @@ module Utopia
|
|
178
178
|
|
179
179
|
next unless File.directory?(guide_path)
|
180
180
|
|
181
|
-
yield Guide.new(self, guide_path)
|
181
|
+
yield Guide.new(self, guide_path, link.info)
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -203,6 +203,20 @@ module Utopia
|
|
203
203
|
releases_document.releases
|
204
204
|
end
|
205
205
|
end
|
206
|
+
|
207
|
+
# Get the path to the gemspec file for this project.
|
208
|
+
# @returns [String | nil] The relative path to the gemspec file, or nil if not found.
|
209
|
+
private def gemspec_path
|
210
|
+
Dir.glob("*.gemspec", base: @root).first
|
211
|
+
end
|
212
|
+
|
213
|
+
# Load and return the gemspec for this project.
|
214
|
+
# @returns [Gem::Specification | nil] The loaded gemspec, or nil if not found.
|
215
|
+
def gemspec
|
216
|
+
if gemspec_path = self.gemspec_path
|
217
|
+
@gemspec ||= ::Gem::Specification.load(File.join(@root, gemspec_path))
|
218
|
+
end
|
219
|
+
end
|
206
220
|
end
|
207
221
|
end
|
208
222
|
end
|
data/lib/utopia/project/guide.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "utopia/path"
|
7
7
|
require "xrb/reference"
|
@@ -14,9 +14,10 @@ module Utopia
|
|
14
14
|
# Initialize the example with the given root path.
|
15
15
|
# @parameter base [Base] The base instance for the project.
|
16
16
|
# @parameter root [String] The file-system path to the root of the example.
|
17
|
-
def initialize(base, root)
|
17
|
+
def initialize(base, root, metadata)
|
18
18
|
@base = base
|
19
19
|
@root = root
|
20
|
+
@metadata = metadata
|
20
21
|
|
21
22
|
@documentation = nil
|
22
23
|
|
@@ -31,6 +32,39 @@ module Utopia
|
|
31
32
|
# @attribute [String | Nil]
|
32
33
|
attr :description
|
33
34
|
|
35
|
+
# The metadata associated with the guide.
|
36
|
+
# @attribute [Hash]
|
37
|
+
attr :metadata
|
38
|
+
|
39
|
+
def order
|
40
|
+
metadata[:order]
|
41
|
+
end
|
42
|
+
|
43
|
+
def <=> other
|
44
|
+
if order = self.order
|
45
|
+
if other_order = other.order
|
46
|
+
if order < other_order
|
47
|
+
return -1
|
48
|
+
elsif order > other_order
|
49
|
+
return 1
|
50
|
+
end
|
51
|
+
else
|
52
|
+
# If we have order, but the other doesn't, we come first:
|
53
|
+
return -1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if name = self.name
|
58
|
+
if other_name = other.name
|
59
|
+
return name <=> other_name
|
60
|
+
else
|
61
|
+
return -1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
return 0
|
66
|
+
end
|
67
|
+
|
34
68
|
README = "readme.md"
|
35
69
|
|
36
70
|
# The path to the README file for the guide.
|
data/lib/utopia/project.rb
CHANGED
data/pages/controller.rb
CHANGED
data/pages/guides/controller.rb
CHANGED
data/pages/source/controller.rb
CHANGED
data/readme.md
CHANGED
@@ -31,6 +31,14 @@ Please see the [project documentation](https://socketry.github.io/utopia-project
|
|
31
31
|
|
32
32
|
Please see the [project releases](https://socketry.github.io/utopia-project/releases/index) for all releases.
|
33
33
|
|
34
|
+
### v0.34.1
|
35
|
+
|
36
|
+
- Fix schema for `index.yaml` context file.
|
37
|
+
|
38
|
+
### v0.34.0
|
39
|
+
|
40
|
+
- Introduce `bake utopia:project:agent:context:update` command to update the agent context from the guides in the project.
|
41
|
+
|
34
42
|
### v0.33.2
|
35
43
|
|
36
44
|
- Fixed handling of segmented code guides when rendered into a `readme.md` file.
|
data/releases.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## v0.34.1
|
4
|
+
|
5
|
+
- Fix schema for `index.yaml` context file.
|
6
|
+
|
7
|
+
## v0.34.0
|
8
|
+
|
9
|
+
- Introduce `bake utopia:project:agent:context:update` command to update the agent context from the guides in the project.
|
10
|
+
|
3
11
|
## v0.33.2
|
4
12
|
|
5
13
|
- Fixed handling of segmented code guides when rendered into a `readme.md` file.
|
data/template/gems.rb
CHANGED
data/template/preload.rb
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.34.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -130,7 +130,12 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- bake/utopia/project.rb
|
133
|
+
- bake/utopia/project/agent/context.rb
|
133
134
|
- bake/utopia/project/readme/update.rb
|
135
|
+
- context/documentation-formatting.md
|
136
|
+
- context/getting-started.md
|
137
|
+
- context/github-pages-integration.md
|
138
|
+
- context/index.yaml
|
134
139
|
- lib/utopia/project.rb
|
135
140
|
- lib/utopia/project/base.md
|
136
141
|
- lib/utopia/project/base.rb
|
@@ -278,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
283
|
- !ruby/object:Gem::Version
|
279
284
|
version: '0'
|
280
285
|
requirements: []
|
281
|
-
rubygems_version: 3.6.
|
286
|
+
rubygems_version: 3.6.9
|
282
287
|
specification_version: 4
|
283
288
|
summary: A project documentation tool based on Utopia.
|
284
289
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|