anatomy 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b1866167079bd12d6c8a8b88e0e5bc1fef6e3e6
4
- data.tar.gz: 8f9c538fef7531f68821d1738274ec3a894c0ff1
3
+ metadata.gz: 4e757a65ff4fed2d3f03bb130eb79d72a468c427
4
+ data.tar.gz: 3dc6b84202c1d4e651c0cc4dd613835c9594284c
5
5
  SHA512:
6
- metadata.gz: 7f7e76d01f543a073fa21c3e2da7f6f529bd0d0c6ef541a8142688aaa273f56ec6dc08b064352df348caa114873482298642b11c455d5ff3dd0762bbf828984b
7
- data.tar.gz: de3384e79962ddee5a707b373629361a34bd276abb2f199440a3284d7038a2965557378d3d1475f06e8e92648245a6f68763287b77958a67ea5ba4a36c75a780
6
+ metadata.gz: 18e5b6316e4be8867d4fe8facffacb915480ce7f1c5b80593c18f37cf0cab9c140cfc879daf0190d72891f5f32c6cccd2f6c7bd8e30696ba042744eb361d641f
7
+ data.tar.gz: 550a07ef905b7ee07bce55a9506520a25f777d17800475d1c97ebadd156aac6998d5594e10c2152e0ce2d1e6ead49373bd64c5a65ac1bcbdb591c1e3c01ac8a0
data/lib/anatomy/data.ay CHANGED
@@ -81,6 +81,17 @@ def(Part set-local-tag(name, target = nil, display = nil)):
81
81
 
82
82
  def(Part toc?): style properties include?(.toc)
83
83
 
84
+ def(Part section-label):
85
+ if(@parent)
86
+ then:
87
+ parent-label = @parent section-label
88
+ self-index = (@parent parts index(self) + 1)
89
+
90
+ if(parent-label empty?)
91
+ then: i"#{self-index}"
92
+ else: i"#{parent-label}.#{self-index}"
93
+ else: ""
94
+
84
95
  def(Part inspect): i"#<Part: '#{@tag name}'>"
85
96
 
86
97
  -- search in order:
@@ -8,8 +8,10 @@ require("fileutils")
8
8
  use(require("anatomy/html"))
9
9
  data = require("anatomy/data")
10
10
 
11
- in-reference? = dynamic(false)
12
- in-sidebar? = dynamic(false)
11
+ omit-aux-var? = dynamic(false)
12
+
13
+ def(omit-aux?):
14
+ omit-aux-var?
13
15
 
14
16
  fn(tag-url(t)):
15
17
  t target match:
@@ -141,7 +143,7 @@ fn(element-style(style, content)):
141
143
  <script(async = true, defer = true, src = url) {}
142
144
 
143
145
  .aux:
144
- unless(^(in-reference?) || ^(in-sidebar?)):
146
+ unless(^(omit-aux?)):
145
147
  over(content)
146
148
 
147
149
  .newline:
@@ -180,7 +182,7 @@ def(over(p & data Reference)):
180
182
  if(p tag)
181
183
  then:
182
184
  <a(href = tag-url(p tag)):
183
- with(in-reference? = true):
185
+ with(omit-aux? = true):
184
186
  over(p content)
185
187
  else:
186
188
  <a(.undefined): over(p content)
@@ -246,6 +248,8 @@ def(render(part, out = ".")):
246
248
  File open(i"#{out}/public/tags.js", "w") [f]:
247
249
  f write(i"var SEARCH_TAGS = #{tags to-json};")
248
250
 
251
+ copy-all-assets(part, out)
252
+
249
253
  -- call this early so the template can register its own assets/etc
250
254
  template = render-part-template(part, out)
251
255
 
@@ -290,10 +294,28 @@ def(render(part, out = ".")):
290
294
  ")
291
295
  })
292
296
 
297
+ -- now that everything's generated, copy all recorded assets over (note that
298
+ -- templates may register their own assets)
299
+ unless(part parent):
300
+ copy-all-assets(part, out)
301
+
293
302
  def(render-part-template(part, out = ".")):
294
- copy-part-assets(part, out)
295
303
  (part template || Self) template-for(part, out)
296
304
 
305
+ def(all-part-assets(part)):
306
+ assets = part assets to-a
307
+
308
+ assets += part css-additions to-a
309
+
310
+ part parts collect [sub]:
311
+ assets += all-part-assets(sub)
312
+
313
+ assets
314
+
315
+ def(copy-all-assets(part, out)):
316
+ all-part-assets(part) each [a]:
317
+ sync-asset-to(a, out)
318
+
297
319
  def(template-for(part, out)):
298
320
  <div(#page):
299
321
  <div(#main):
@@ -310,7 +332,7 @@ def(template-for(part, out)):
310
332
 
311
333
  <ul(.search-results) {}
312
334
 
313
- with(in-sidebar? = true):
335
+ with(omit-aux? = true):
314
336
  <div(#sidebar):
315
337
  <h2:
316
338
  <a(href = url(part top)):
@@ -336,15 +358,20 @@ def(render-part(part, out = ".", depth = 1)):
336
358
  toc-leaf(part, sub)
337
359
  else:
338
360
  part parts collect [sub]:
339
- copy-part-assets(sub, out)
340
361
  render-part(sub, out, depth + 1)
341
362
 
342
- def(copy-part-assets(part, out)):
343
- part assets each [a]:
344
- FileUtils cp_r(a, out, #{.remove_destination -> true})
363
+ def(sync-asset-to(path, outdir)):
364
+ if(File directory?(path))
365
+ then:
366
+ subdir = File join(outdir, File basename(path))
345
367
 
346
- part css-additions each [a]:
347
- FileUtils cp_r(a, out)
368
+ Dir entries(path) each [entry]:
369
+ when((entry != ".") && (entry != "..")):
370
+ sync-asset-to(File join(path, entry), subdir)
371
+
372
+ else:
373
+ FileUtils mkdir_p(outdir)
374
+ FileUtils cp(path, File join(outdir, File basename(path)))
348
375
 
349
376
  def(search-tags(p)):
350
377
  tags = [
@@ -390,15 +417,16 @@ def(search-tags(p)):
390
417
  tags
391
418
 
392
419
  def(all-css-additions(p)):
393
- assets =
394
- p css-additions to-a collect [file]:
395
- File basename(file)
420
+ all-assets = Set new
421
+
422
+ p css-additions each [file]:
423
+ all-assets << File basename(file)
396
424
 
397
- assets += p css-url-additions to-a
425
+ all-assets += p css-url-additions
398
426
 
399
427
  p parts each [sub]:
400
428
  -- exclude parts that have their own page
401
429
  unless(top(sub) == sub):
402
- assets += all-css-additions(sub)
430
+ all-assets += all-css-additions(sub)
403
431
 
404
- assets
432
+ all-assets
@@ -53,6 +53,10 @@ def(pass(a & Array, part, body = part body)):
53
53
  def(pass(p & data Part, part, body = part body)):
54
54
  part parts << p
55
55
  p parent = part
56
+
57
+ unless(p template):
58
+ p template = part template
59
+
56
60
  part body freeze
57
61
  nil
58
62
 
@@ -1,3 +1,3 @@
1
1
  module Anatomy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anatomy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Suraci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: atomy
15
- type: :runtime
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: 0.6.3
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -26,12 +26,12 @@ dependencies:
26
26
  version: 0.6.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: broomhlda
29
- type: :runtime
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
33
  version: 0.2.0
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -40,12 +40,12 @@ dependencies:
40
40
  version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json_pure
43
- type: :runtime
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
47
  version: '1.8'
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -54,12 +54,12 @@ dependencies:
54
54
  version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
- type: :development
58
57
  requirement: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - "~>"
61
60
  - !ruby/object:Gem::Version
62
61
  version: '10.4'
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project: anatomy
121
- rubygems_version: 2.5.1
121
+ rubygems_version: 2.4.5.1
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Anatomy documentation system