gem_docs 0.1.0 → 0.2.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/lib/gem_docs/emacs.rb +7 -5
- data/lib/gem_docs/header.rb +1 -4
- data/lib/gem_docs/overview.rb +8 -4
- data/lib/gem_docs/tasks.rb +4 -13
- data/lib/gem_docs/version.rb +1 -1
- data/lib/gem_docs.rb +31 -10
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5eadd7f7e5421dca33c5297a35fd54283a002b6f87757796aaa697e5ba39ce50
|
|
4
|
+
data.tar.gz: 3dd763c1846d02c694a0c9aa85a56e59cae9be90a661778dc94a0ab95a5ba971
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e18a7cdf17f776fca792566409e1b9d5f9ab1119e20980d7d204f116204461dd6e335b5bcb79ad5ba5d05abc6594780517e76fe4f86458d8b15c1fd0a8d1df0f
|
|
7
|
+
data.tar.gz: baef0a42000b8f28f8721e3502b694669a8a1c335f5a82f2bd45344e10494bfffe792e93e83bcfba8470fdad1ab533b0b1ada895def53ec4a1b3a0c088f64cf7
|
data/lib/gem_docs/emacs.rb
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
module GemDocs
|
|
4
4
|
module Emacs
|
|
5
5
|
def self.tangle
|
|
6
|
-
# ensure_saved
|
|
7
6
|
expr = <<~ELISP
|
|
8
7
|
(save-window-excursion
|
|
8
|
+
(if (get-buffer "#{session_name}")
|
|
9
|
+
(kill-buffer "#{session_name}"))
|
|
9
10
|
(with-current-buffer (find-file-noselect "#{README_ORG}")
|
|
10
11
|
(save-buffer)
|
|
11
12
|
(require 'ob-ruby)
|
|
@@ -14,15 +15,12 @@ module GemDocs
|
|
|
14
15
|
"OK"))
|
|
15
16
|
ELISP
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
FileUtils.touch(STAMP)
|
|
19
|
-
else
|
|
18
|
+
unless system("emacsclient", "--quiet", "--eval", expr)
|
|
20
19
|
abort "Babel execution failed"
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def self.export
|
|
25
|
-
# ensure_saved
|
|
26
24
|
expr = <<~ELISP
|
|
27
25
|
(save-window-excursion
|
|
28
26
|
(with-current-buffer (find-file-noselect "#{README_ORG}")
|
|
@@ -33,5 +31,9 @@ module GemDocs
|
|
|
33
31
|
|
|
34
32
|
system("emacsclient", "--quiet", "--eval", expr)
|
|
35
33
|
end
|
|
34
|
+
|
|
35
|
+
def self.session_name
|
|
36
|
+
"*#{Repo.from_gemspec.name}_session*"
|
|
37
|
+
end
|
|
36
38
|
end
|
|
37
39
|
end
|
data/lib/gem_docs/header.rb
CHANGED
|
@@ -9,7 +9,7 @@ module GemDocs
|
|
|
9
9
|
return false if present?
|
|
10
10
|
|
|
11
11
|
prelim, body = extract_prelim_body
|
|
12
|
-
new_org = prelim.join.strip + org_headers.strip + "\n\n" + body.join
|
|
12
|
+
new_org = prelim.join.strip + "\n" + org_headers.strip + "\n\n" + body.join
|
|
13
13
|
File.write(README_ORG, new_org) > 0
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -32,9 +32,6 @@ module GemDocs
|
|
|
32
32
|
body << line
|
|
33
33
|
elsif in_prelim && (line.match(/^#/) || line.match(/^\s*$/))
|
|
34
34
|
prelim << line
|
|
35
|
-
# elsif in_prelim
|
|
36
|
-
# in_prelim = false
|
|
37
|
-
# body << line
|
|
38
35
|
else
|
|
39
36
|
body << line
|
|
40
37
|
end
|
data/lib/gem_docs/overview.rb
CHANGED
|
@@ -35,8 +35,12 @@ module GemDocs
|
|
|
35
35
|
old_lib.sub(old_comment, new_comment)
|
|
36
36
|
else
|
|
37
37
|
scanner = StringScanner.new(old_lib)
|
|
38
|
-
scanner.scan_until(/^module #{repo.module_name}/)
|
|
39
|
-
|
|
38
|
+
if scanner.scan_until(/^module #{repo.module_name}/)
|
|
39
|
+
scanner.pre_match + "\n" + new_comment + "\n" + scanner.matched + scanner.rest
|
|
40
|
+
else
|
|
41
|
+
# No `module GemName` in the file. Add empty one at the end
|
|
42
|
+
old_lib + "\n" + new_comment + "\nmodule #{repo.module_name}\nend"
|
|
43
|
+
end
|
|
40
44
|
end
|
|
41
45
|
File.write(target, new_lib) > 0
|
|
42
46
|
end
|
|
@@ -79,7 +83,7 @@ module GemDocs
|
|
|
79
83
|
scanner = StringScanner.new(text)
|
|
80
84
|
heads.each do |h|
|
|
81
85
|
if scanner.scan_until(/\n(?<head>\s*\*\s+#{Regexp.escape(h)})[^\n]*\n/)
|
|
82
|
-
this_head = scanner.named_captures['head'] + "\n
|
|
86
|
+
this_head = scanner.named_captures['head'] + "\n"
|
|
83
87
|
body_start = scanner.pos
|
|
84
88
|
body_end =
|
|
85
89
|
if scanner.scan_until(/\n^\s*\*[^\*\n]+/)
|
|
@@ -91,7 +95,7 @@ module GemDocs
|
|
|
91
95
|
result << this_head + scanner.string[body_start..body_end]
|
|
92
96
|
end
|
|
93
97
|
end
|
|
94
|
-
result
|
|
98
|
+
result.sub(/\A\n*/, '')
|
|
95
99
|
end
|
|
96
100
|
end
|
|
97
101
|
end
|
data/lib/gem_docs/tasks.rb
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module GemDocs
|
|
4
|
-
extend Rake::DSL
|
|
5
|
-
|
|
6
|
-
STAMP = ".tangle-stamp"
|
|
7
|
-
|
|
8
4
|
def self.install
|
|
9
5
|
extend Rake::DSL
|
|
10
6
|
|
|
@@ -14,16 +10,12 @@ module GemDocs
|
|
|
14
10
|
GemDocs::Emacs.export
|
|
15
11
|
end
|
|
16
12
|
|
|
17
|
-
# Evaluate code blocks only when README.org changes
|
|
18
|
-
file STAMP => README_ORG do
|
|
19
|
-
print "Executing code blocks in #{README_ORG} ... "
|
|
20
|
-
GemDocs::Emacs.tangle
|
|
21
|
-
FileUtils.touch(STAMP)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
13
|
namespace :docs do
|
|
25
14
|
desc "Evaluate code blocks in README.org"
|
|
26
|
-
task :tangle => [:skeleton
|
|
15
|
+
task :tangle => [:skeleton] do
|
|
16
|
+
print "Executing code blocks in #{README_ORG} ... "
|
|
17
|
+
GemDocs::Emacs.tangle
|
|
18
|
+
end
|
|
27
19
|
|
|
28
20
|
desc "Export README.org → README.md"
|
|
29
21
|
task :export => [:badge, README_MD]
|
|
@@ -66,7 +58,6 @@ module GemDocs
|
|
|
66
58
|
desc "Ensure GitHub Actions badge exists in README.org"
|
|
67
59
|
task :badge => :skeleton do
|
|
68
60
|
print "Ensuring badges are in README.org ... "
|
|
69
|
-
|
|
70
61
|
if GemDocs::Badge.ensure!
|
|
71
62
|
puts "added"
|
|
72
63
|
else
|
data/lib/gem_docs/version.rb
CHANGED
data/lib/gem_docs.rb
CHANGED
|
@@ -11,10 +11,7 @@ require "fileutils"
|
|
|
11
11
|
|
|
12
12
|
# Gem Overview (extracted from README.org by gem_docs)
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
14
|
# * Overview
|
|
17
|
-
#
|
|
18
15
|
# One of the more onerous tasks when writing a ~gem~ or other ~github~ project
|
|
19
16
|
# is maintaining the documentation, and keeping it consistent and up-to-date.
|
|
20
17
|
# One of the better options for writing the ~README~ file that gets displayed by
|
|
@@ -46,7 +43,6 @@ require "fileutils"
|
|
|
46
43
|
# main gem library file so it gets picked up as an overview for ~ri~ and ~yri~
|
|
47
44
|
#
|
|
48
45
|
# * Usage
|
|
49
|
-
#
|
|
50
46
|
# ** Create a skeleton README.org file
|
|
51
47
|
# This is a simple task that creates a bare-bones ~README.org~ file to get
|
|
52
48
|
# started with. It does create the file with the name of the gem and other repo
|
|
@@ -57,7 +53,6 @@ require "fileutils"
|
|
|
57
53
|
# #+end_src
|
|
58
54
|
#
|
|
59
55
|
# ** Add proper ~#+PROPERTY~ headers in ~README.org~: ~rake docs:headers~
|
|
60
|
-
# **
|
|
61
56
|
# Getting emacs code blocks to render well in your ~README.org~ takes proper
|
|
62
57
|
# configuration of the code block headers in Emacs.
|
|
63
58
|
#
|
|
@@ -113,7 +108,13 @@ require "fileutils"
|
|
|
113
108
|
# the gem, etc. Of course, you can override this for particular code blocks.
|
|
114
109
|
#
|
|
115
110
|
# Those headers are in fact what I am using in this ~README~, and here is how
|
|
116
|
-
# they work
|
|
111
|
+
# they work.
|
|
112
|
+
#
|
|
113
|
+
# *** Output Tables
|
|
114
|
+
# You can build table for ~org~ to display in the output by returning an array
|
|
115
|
+
# of arrays, which org-mode renders as a table in the output. You can add an
|
|
116
|
+
# hline to the output table by simply adding ~nil~ to the outer array where you
|
|
117
|
+
# want the hline to occur.
|
|
117
118
|
#
|
|
118
119
|
# #+begin_src ruby
|
|
119
120
|
# result = []
|
|
@@ -142,10 +143,25 @@ require "fileutils"
|
|
|
142
143
|
# | 3.3333333333333335 | 28.03162489452614 |
|
|
143
144
|
# #+end_example
|
|
144
145
|
#
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
146
|
+
# *** Output Values
|
|
147
|
+
# Sometimes, however, you just want the result of the code block evaluated
|
|
148
|
+
# without building a table. To do so, just set the block header to ~:results
|
|
149
|
+
# value raw~.
|
|
150
|
+
#
|
|
151
|
+
# To compute the value of an $1,000 asset gaining 5% continuously compounding
|
|
152
|
+
# interest over four years, you might do this:
|
|
153
|
+
#
|
|
154
|
+
# #+begin_src ruby :results value raw
|
|
155
|
+
# rate = 0.05
|
|
156
|
+
# time = 4
|
|
157
|
+
# principal = 1000
|
|
158
|
+
# principal * Math.exp(rate * time)
|
|
159
|
+
# #+end_src
|
|
160
|
+
#
|
|
161
|
+
# #+RESULTS:
|
|
162
|
+
# #+begin_example
|
|
163
|
+
# 1221.40275816017
|
|
164
|
+
# #+end_example
|
|
149
165
|
#
|
|
150
166
|
# Apart from all the convenient markup that ~org-mode~ allows, the ability to
|
|
151
167
|
# easily demonstrate your gem's code in this way is the real killer feature of
|
|
@@ -174,6 +190,11 @@ require "fileutils"
|
|
|
174
190
|
# rake docs:tangle
|
|
175
191
|
# #+end_src
|
|
176
192
|
#
|
|
193
|
+
# With the default headers provided by `rake docs:headers`, the buffer is
|
|
194
|
+
# evaluated in a session so that code blocks can build on one another. However,
|
|
195
|
+
# `docs:tangle` kills any existing session buffer before it runs so that each
|
|
196
|
+
# buffer evaluation is independent of earlier runs.
|
|
197
|
+
#
|
|
177
198
|
# ** Ensure that a Badge is Present in ~README.md~: ~rake docs:badge~
|
|
178
199
|
# It is reassuring to consumers of your gem that your gem passes its workflow
|
|
179
200
|
# tests on github. This task checks to see if a "badge" indicating success or
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_docs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-12-
|
|
10
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rake
|
|
@@ -27,18 +27,18 @@ dependencies:
|
|
|
27
27
|
name: yard
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0
|
|
32
|
+
version: '0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- - "
|
|
37
|
+
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0
|
|
40
|
-
description: Shared tasks for README.org execution,
|
|
41
|
-
etc.
|
|
39
|
+
version: '0'
|
|
40
|
+
description: Shared tasks for README.org code block execution, markdown export, YARD
|
|
41
|
+
integration, etc.
|
|
42
42
|
email:
|
|
43
43
|
- ded@ddoherty.net
|
|
44
44
|
executables: []
|