trifle-docs 0.5.0 → 0.6.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/Gemfile.lock +15 -11
- data/lib/trifle/docs/app.rb +26 -0
- data/lib/trifle/docs/engine.rb +35 -1
- data/lib/trifle/docs/helper/llms.rb +69 -0
- data/lib/trifle/docs/version.rb +1 -1
- data/lib/trifle/docs.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfae89cd75902acfa8a8b3c23e082e9820e6af13f05a8f69c0e955ae0fe65f56
|
|
4
|
+
data.tar.gz: db34713f816c8ad860930a85ce198654fcb1adbe91716a308db3a8b11c941fb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec86cf47abf1b3d8534ae6fce439d353e694fb443c37ac59753e6ca18f7f72330b007e1bdcc1390f0f6b87e3ea89b41ef41db85816059eceb54716bb49ef6d43
|
|
7
|
+
data.tar.gz: c2775f303aec6dfa94a2071fc1722a932d996d907aeb767f58269ee8060d86d5b49b94c42ce67c28a7060175e365434756b446f3b64896ed02e434d825bfc40e
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
trifle-docs (0.
|
|
4
|
+
trifle-docs (0.6.0)
|
|
5
5
|
redcarpet
|
|
6
6
|
rouge
|
|
7
7
|
sinatra
|
|
@@ -14,7 +14,8 @@ GEM
|
|
|
14
14
|
base64 (0.3.0)
|
|
15
15
|
byebug (11.1.3)
|
|
16
16
|
diff-lcs (1.5.0)
|
|
17
|
-
|
|
17
|
+
logger (1.7.0)
|
|
18
|
+
mustermann (3.0.4)
|
|
18
19
|
ruby2_keywords (~> 0.0.1)
|
|
19
20
|
nio4r (2.7.4)
|
|
20
21
|
parallel (1.22.1)
|
|
@@ -22,18 +23,20 @@ GEM
|
|
|
22
23
|
ast (~> 2.4.1)
|
|
23
24
|
puma (6.6.0)
|
|
24
25
|
nio4r (~> 2.0)
|
|
25
|
-
rack (3.
|
|
26
|
-
rack-protection (4.
|
|
26
|
+
rack (3.2.4)
|
|
27
|
+
rack-protection (4.2.1)
|
|
27
28
|
base64 (>= 0.1.0)
|
|
29
|
+
logger (>= 1.6.0)
|
|
28
30
|
rack (>= 3.0.0, < 4)
|
|
29
|
-
rack-session (2.
|
|
31
|
+
rack-session (2.1.1)
|
|
32
|
+
base64 (>= 0.1.0)
|
|
30
33
|
rack (>= 3.0.0)
|
|
31
34
|
rainbow (3.1.1)
|
|
32
35
|
rake (13.0.6)
|
|
33
|
-
redcarpet (3.6.
|
|
36
|
+
redcarpet (3.6.1)
|
|
34
37
|
regexp_parser (2.5.0)
|
|
35
38
|
rexml (3.2.5)
|
|
36
|
-
rouge (4.
|
|
39
|
+
rouge (4.7.0)
|
|
37
40
|
rspec (3.11.0)
|
|
38
41
|
rspec-core (~> 3.11.0)
|
|
39
42
|
rspec-expectations (~> 3.11.0)
|
|
@@ -60,15 +63,16 @@ GEM
|
|
|
60
63
|
parser (>= 3.1.1.0)
|
|
61
64
|
ruby-progressbar (1.11.0)
|
|
62
65
|
ruby2_keywords (0.0.5)
|
|
63
|
-
sinatra (4.
|
|
66
|
+
sinatra (4.2.1)
|
|
67
|
+
logger (>= 1.6.0)
|
|
64
68
|
mustermann (~> 3.0)
|
|
65
69
|
rack (>= 3.0.0, < 4)
|
|
66
|
-
rack-protection (= 4.
|
|
70
|
+
rack-protection (= 4.2.1)
|
|
67
71
|
rack-session (>= 2.0.0, < 3)
|
|
68
72
|
tilt (~> 2.0)
|
|
69
|
-
tilt (2.
|
|
73
|
+
tilt (2.7.0)
|
|
70
74
|
unicode-display_width (2.1.0)
|
|
71
|
-
yaml (0.
|
|
75
|
+
yaml (0.4.0)
|
|
72
76
|
|
|
73
77
|
PLATFORMS
|
|
74
78
|
arm64-darwin-21
|
data/lib/trifle/docs/app.rb
CHANGED
|
@@ -25,6 +25,32 @@ module Trifle
|
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
get '/llms.txt' do
|
|
29
|
+
meta = Trifle::Docs.meta(url: 'llms.txt')
|
|
30
|
+
if meta && meta['type'] == 'file'
|
|
31
|
+
return send_file(meta['path'])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
content = Trifle::Docs::Helper::Llms.homepage_markdown
|
|
35
|
+
halt(404, 'Not Found') if content.nil?
|
|
36
|
+
|
|
37
|
+
content_type 'text/markdown'
|
|
38
|
+
content
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
get '/llms-full.txt' do
|
|
42
|
+
meta = Trifle::Docs.meta(url: 'llms-full.txt')
|
|
43
|
+
if meta && meta['type'] == 'file'
|
|
44
|
+
return send_file(meta['path'])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
content = Trifle::Docs::Helper::Llms.full_markdown
|
|
48
|
+
halt(404, 'Not Found') if content.nil? || content.strip.empty?
|
|
49
|
+
|
|
50
|
+
content_type 'text/markdown'
|
|
51
|
+
content
|
|
52
|
+
end
|
|
53
|
+
|
|
28
54
|
get '/*' do
|
|
29
55
|
url = params['splat'].first.chomp('/')
|
|
30
56
|
meta = Trifle::Docs.meta(url: url)
|
data/lib/trifle/docs/engine.rb
CHANGED
|
@@ -17,6 +17,8 @@ if Object.const_defined?('Rails')
|
|
|
17
17
|
def self.draw
|
|
18
18
|
Trifle::Docs::Engine.routes.draw do
|
|
19
19
|
root to: 'page#show'
|
|
20
|
+
get 'llms.txt', to: 'page#llms'
|
|
21
|
+
get 'llms-full.txt', to: 'page#llms_full'
|
|
20
22
|
get 'search', to: 'page#search'
|
|
21
23
|
get '*url', to: 'page#show'
|
|
22
24
|
end
|
|
@@ -60,6 +62,38 @@ if Object.const_defined?('Rails')
|
|
|
60
62
|
}
|
|
61
63
|
end
|
|
62
64
|
|
|
65
|
+
def llms
|
|
66
|
+
meta = Trifle::Docs.meta(url: 'llms.txt', config: configuration)
|
|
67
|
+
if meta && meta['type'] == 'file'
|
|
68
|
+
send_file(meta['path'])
|
|
69
|
+
return
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
content = Trifle::Docs::Helper::Llms.homepage_markdown(config: configuration)
|
|
73
|
+
if content.nil?
|
|
74
|
+
render_not_found
|
|
75
|
+
return
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
render plain: content, content_type: 'text/markdown'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def llms_full
|
|
82
|
+
meta = Trifle::Docs.meta(url: 'llms-full.txt', config: configuration)
|
|
83
|
+
if meta && meta['type'] == 'file'
|
|
84
|
+
send_file(meta['path'])
|
|
85
|
+
return
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
content = Trifle::Docs::Helper::Llms.full_markdown(config: configuration)
|
|
89
|
+
if content.nil? || content.strip.empty?
|
|
90
|
+
render_not_found
|
|
91
|
+
return
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
render plain: content, content_type: 'text/markdown'
|
|
95
|
+
end
|
|
96
|
+
|
|
63
97
|
def render_not_found
|
|
64
98
|
render text: 'Not Found', status: 404
|
|
65
99
|
end
|
|
@@ -78,7 +112,7 @@ if Object.const_defined?('Rails')
|
|
|
78
112
|
}
|
|
79
113
|
end
|
|
80
114
|
|
|
81
|
-
def render_markdown
|
|
115
|
+
def render_markdown(url:, meta:)
|
|
82
116
|
render plain: Trifle::Docs::Helper::MarkdownLayout.render(
|
|
83
117
|
meta: meta,
|
|
84
118
|
raw_content: Trifle::Docs.raw_content(url: url, config: configuration),
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Trifle
|
|
4
|
+
module Docs
|
|
5
|
+
module Helper
|
|
6
|
+
module Llms
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def homepage_markdown(config: nil)
|
|
10
|
+
meta = Trifle::Docs.meta(url: '', config: config)
|
|
11
|
+
return nil if meta.nil?
|
|
12
|
+
|
|
13
|
+
Trifle::Docs::Helper::MarkdownLayout.render(
|
|
14
|
+
meta: meta,
|
|
15
|
+
raw_content: Trifle::Docs.raw_content(url: '', config: config),
|
|
16
|
+
sitemap: Trifle::Docs.sitemap(config: config)
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def full_markdown(config: nil)
|
|
21
|
+
sitemap = Trifle::Docs.sitemap(config: config)
|
|
22
|
+
pages = flatten_sitemap(sitemap)
|
|
23
|
+
|
|
24
|
+
chunks = pages.filter_map do |page|
|
|
25
|
+
meta = page[:meta]
|
|
26
|
+
next if meta.nil? || meta['type'] == 'file'
|
|
27
|
+
|
|
28
|
+
raw = Trifle::Docs.raw_content(url: page[:url], config: config)
|
|
29
|
+
next if raw.nil? || raw.strip.empty?
|
|
30
|
+
|
|
31
|
+
format_page(meta: meta, url: page[:url], raw_content: raw)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
chunks.join("\n\n")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def flatten_sitemap(node, path = [])
|
|
38
|
+
return [] unless node.is_a?(Hash)
|
|
39
|
+
|
|
40
|
+
entries = []
|
|
41
|
+
meta = node['_meta']
|
|
42
|
+
entries << { url: path.join('/'), meta: meta } if meta
|
|
43
|
+
|
|
44
|
+
node.keys.reject { |key| key == '_meta' }.sort.each do |key|
|
|
45
|
+
entries.concat(flatten_sitemap(node[key], path + [key]))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
entries
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def format_page(meta:, url:, raw_content:)
|
|
52
|
+
title = meta['title'] || Trifle::Docs::Helper::MarkdownLayout.derive_title_from_url(url)
|
|
53
|
+
page_url = meta['url'] || "/#{url}"
|
|
54
|
+
|
|
55
|
+
lines = []
|
|
56
|
+
lines << "# #{title}"
|
|
57
|
+
lines << ''
|
|
58
|
+
lines << "Source: #{page_url}"
|
|
59
|
+
lines << ''
|
|
60
|
+
lines << raw_content.to_s.strip
|
|
61
|
+
lines << ''
|
|
62
|
+
lines << '---'
|
|
63
|
+
|
|
64
|
+
lines.join("\n")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/lib/trifle/docs/version.rb
CHANGED
data/lib/trifle/docs.rb
CHANGED
|
@@ -4,6 +4,7 @@ require_relative 'docs/configuration'
|
|
|
4
4
|
require_relative 'docs/helper/tree'
|
|
5
5
|
require_relative 'docs/helper/markdown_layout'
|
|
6
6
|
require_relative 'docs/helper/ai_detection'
|
|
7
|
+
require_relative 'docs/helper/llms'
|
|
7
8
|
require_relative 'docs/harvester'
|
|
8
9
|
require_relative 'docs/harvester/file'
|
|
9
10
|
require_relative 'docs/harvester/markdown'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trifle-docs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jozef Vaclavik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -201,6 +201,7 @@ files:
|
|
|
201
201
|
- lib/trifle/docs/harvester/file.rb
|
|
202
202
|
- lib/trifle/docs/harvester/markdown.rb
|
|
203
203
|
- lib/trifle/docs/helper/ai_detection.rb
|
|
204
|
+
- lib/trifle/docs/helper/llms.rb
|
|
204
205
|
- lib/trifle/docs/helper/markdown_layout.rb
|
|
205
206
|
- lib/trifle/docs/helper/tree.rb
|
|
206
207
|
- lib/trifle/docs/operations/collection.rb
|