Explorar el Código

Test documentation;

bjorn hace 10 años
padre
commit
4fa777c41d
Se han modificado 2 ficheros con 82 adiciones y 1 borrados
  1. 49 0
      doc/README.md
  2. 33 1
      tools/update_documentation.lua

+ 49 - 0
doc/README.md

@@ -1,3 +1,52 @@
+- [Observer](#Observer)
+  - [create](#`.create(onNext,-onError,-onComplete)`)
+  - [onNext](#`:onNext(values)`)
+  - [onError](#`:onError(message)`)
+  - [onComplete](#`:onComplete()`)
+- [Observable](#Observable)
+  - [create](#`.create(subscribe)`)
+  - [fromValue](#`.fromValue(value)`)
+  - [fromRange](#`.fromRange(initial,-limit,-step)`)
+  - [fromTable](#`.fromTable(table,-iterator)`)
+  - [fromCoroutine](#`.fromCoroutine(coroutine)`)
+  - [subscribe](#`:subscribe(onNext,-onError,-onComplete)`)
+  - [dump](#`:dump(name)`)
+  - [combineLatest](#`:combineLatest(observables,-combinator)`)
+  - [concat](#`:concat(sources)`)
+  - [distinct](#`:distinct()`)
+  - [filter](#`:filter(predicate)`)
+  - [find](#`:find(predicate)`)
+  - [first](#`:first()`)
+  - [flatten](#`:flatten()`)
+  - [last](#`:last()`)
+  - [map](#`:map(callback)`)
+  - [max](#`:max()`)
+  - [min](#`:min()`)
+  - [merge](#`:merge(sources)`)
+  - [pack](#`:pack()`)
+  - [pluck](#`:pluck(key)`)
+  - [reduce](#`:reduce(accumulator,-seed)`)
+  - [skip](#`:skip(n)`)
+  - [skipUntil](#`:skipUntil(other)`)
+  - [sum](#`:sum()`)
+  - [take](#`:take(n)`)
+  - [takeUntil](#`:takeUntil(other)`)
+  - [unpack](#`:unpack()`)
+  - [unwrap](#`:unwrap()`)
+- [Scheduler](#Scheduler)
+- [CooperativeScheduler](#CooperativeScheduler)
+  - [create](#`.create(currentTime)`)
+  - [schedule](#`:schedule(action,-delay)`)
+  - [update](#`:update(delta)`)
+  - [isEmpty](#`:isEmpty()`)
+- [Subject](#Subject)
+  - [create](#`.create(value)`)
+  - [subscribe](#`:subscribe(onNext,-onError,-onComplete)`)
+  - [onNext](#`:onNext(values)`)
+  - [onError](#`:onError(message)`)
+  - [onComplete](#`:onComplete()`)
+  - [getValue](#`:getValue()`)
+
 # Observer
 # Observer
 
 
 Observers are simple objects that receive values from Observables.
 Observers are simple objects that receive values from Observables.

+ 33 - 1
tools/update_documentation.lua

@@ -2,7 +2,39 @@ local docroc = require 'tools/docroc'
 
 
 io.output('doc/README.md')
 io.output('doc/README.md')
 
 
-for _, comment in ipairs(docroc.process('rx.lua')) do
+local comments = docroc.process('rx.lua')
+
+-- Generate table of contents
+for _, comment in ipairs(comments) do
+  local tags = comment.tags
+
+  if tags.class then
+    local class = tags.class[1].name
+    io.write('- [' .. class .. '](#' .. class .. ')\n')
+  else
+    local context = comment.context:match('function.-([:%.].+)')
+    if tags.arg then
+      context = context:gsub('%b()', function(signature)
+        local args = {}
+
+        for _, arg in ipairs(tags.arg) do
+          table.insert(args, arg.name)
+        end
+
+        return '(' .. table.concat(args, ', ') .. ')'
+      end)
+    end
+
+    local name = comment.context:match('function.-[:%.]([^%(]+)')
+
+    io.write('  - [' .. name .. '](#`' .. context:gsub(' ', '-') .. '`)\n')
+  end
+end
+
+io.write('\n')
+
+-- Generate content
+for _, comment in ipairs(comments) do
   local tags = comment.tags
   local tags = comment.tags
 
 
   if tags.class then
   if tags.class then