utopia-project 0.20.3 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 883f693f304d3d472fdcc8b978298eddcb6c509a79f32527d2af4513a3ae793a
4
- data.tar.gz: f11205cf2b75b905c4e0e8993a63a5a07a73b77c9c0757b2de943ca3e01f8877
3
+ metadata.gz: af7ac04b71cc8b501069888bd23a5da5cd00bd25d7900016fe89de7e08170426
4
+ data.tar.gz: fba0add2c28c7712a0c6fd894b21aca3f0015c3fc13f3c4b0299aa053e4dca9a
5
5
  SHA512:
6
- metadata.gz: c5ca69c795b5977ef5e458fb3a1aef5b092fa66efcb7d5efd78ca9e6894737e3ea34ca45e76cd5ec8bbb1d2e387e3088c4474fcb70cb160ca0ecb8c426e963c2
7
- data.tar.gz: 035e256b161d7fa6777498fa20fb0eaa4f1b5ef092209d0ed339f0585f3401fdc331d3359b0b6459bbc596a357f9b2100f61837fc8c2bccbaa6628e8b3049aeb
6
+ metadata.gz: 0fd2ed330c03e2ba6b4dc2f5ffa7c31d88b6c974b2e1b349c03d882b11ba22cca2fd86aafef63aa09dc18a75d14c1daf766c27b7791c1d3832a67fab00ac22fa
7
+ data.tar.gz: 6d03bc32040379cfab0f3125da19bc05a21a860cded807c695c8b0592b8b6766c200b489988f9f867a42ab4053e5885a839e66c9774321217f59a4d0c0ab0d98
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,50 @@
1
+
2
+ require 'utopia/project'
3
+ require 'trenni'
4
+
5
+ def update(path: "readme.md", documentation_url: nil)
6
+ project = Utopia::Project::Base.new(context.root)
7
+ readme = project.readme_document
8
+
9
+ documentation_url ||= public_documentation_url
10
+
11
+ readme.replace_section("Usage") do |header|
12
+ current = header
13
+
14
+ usage_section = self.usage_section(documentation_url, project)
15
+ usage_section.each do |child|
16
+ current.insert_after(child)
17
+ current = child
18
+ end
19
+ end
20
+
21
+ File.write(path, readme.root.to_markdown)
22
+ end
23
+
24
+ private
25
+
26
+ Scope = Struct.new(:documentation_url, :project)
27
+
28
+ def gemspec_path
29
+ Dir.glob("*.gemspec", base: context.root).first
30
+ end
31
+
32
+ def gemspec
33
+ if gemspec_path = self.gemspec_path
34
+ @gemspec ||= Gem::Specification.load(gemspec_path)
35
+ end
36
+ end
37
+
38
+ # The public documentation URL if it can be determined.
39
+ def public_documentation_url
40
+ gemspec&.homepage
41
+ end
42
+
43
+ def usage_section(documentation_url, project)
44
+ template = Trenni::Template.load_file(File.expand_path("usage.trenni", __dir__))
45
+ scope = Scope.new(documentation_url, project)
46
+
47
+ output = template.to_string(scope)
48
+
49
+ return Markly.parse(output)
50
+ end
@@ -0,0 +1,5 @@
1
+ Please see the [project documentation](#{documentation_url}) for more details.
2
+
3
+ <?r project.guides.each do |guide| ?>
4
+ - [#{guide.title}](#{guide.href(documentation_url)}) - #{guide.description.to_markdown}
5
+ <?r end ?>
@@ -180,7 +180,7 @@ module Utopia
180
180
  end
181
181
 
182
182
  def readme_document
183
- if path = self.path_for('readme.md')
183
+ if path = self.path_for('readme.md') || self.path_for('README.md')
184
184
  Document.new(File.read(path), self)
185
185
  end
186
186
  end
@@ -46,11 +46,12 @@ module Utopia
46
46
  if header.first_child.to_plaintext.include?(name)
47
47
  # Now subsequent children:
48
48
  current = header.next
49
-
49
+
50
50
  # Delete everything in the section until we encounter another header:
51
51
  while current && current.type != :header
52
+ current_next = current.next
52
53
  current.delete
53
- current = current.next
54
+ current = current_next
54
55
  end
55
56
 
56
57
  return yield(header)
@@ -83,8 +83,8 @@ module Utopia
83
83
 
84
84
  # The hypertext reference to this guide.
85
85
  # @returns [String]
86
- def href
87
- "/guides/#{self.name}/index"
86
+ def href(base = "/")
87
+ "#{base}guides/#{self.name}/index"
88
88
  end
89
89
 
90
90
  # The best documentation, extracted from the source files of the guide.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
5
 
6
6
  require 'decode/syntax/rewriter'
7
7
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Utopia
7
7
  module Project
8
- VERSION = "0.20.3"
8
+ VERSION = "0.22.0"
9
9
  end
10
10
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
5
 
6
6
  require "utopia/project/version"
7
7
 
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2020-2022, by Samuel Williams.
3
+ Copyright, 2020-2023, by Samuel Williams.
4
4
  Copyright, 2020, by Olle Jonsson.
5
5
  Copyright, 2022, by dependabot[bot].
6
6
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
5
 
6
6
  prepend Actions
7
7