docs:page: report entries

```
> thor docs:page vue /guide/introduction.html --debug
Entries: (1 KB, +1 KB)
  Updated: 0
  Created: 1
    + 1. Introduction  (Getting Started)
  Deleted: 0
Types:
  Updated: 0
  Created: 1
    + Guide
  Deleted: 0
Files: (0.1 MB, +0.1 MB)
  Updated: 0
  Created: 1
    + guide/introduction
  Deleted: 0
Done
```
pull/1740/head
Simon Legner 3 years ago
parent df0824a300
commit d5147162fe

@ -87,8 +87,15 @@ module Docs
end end
def store_page(store, id) def store_page(store, id)
index = EntryIndex.new
pages = PageDb.new
store.open(path) do store.open(path) do
if page = new.build_page(id) and store_page?(page) if page = new.build_page(id) and store_page?(page)
index.add page[:entries]
pages.add page[:path], page[:output]
store_index(store, INDEX_FILENAME, index, false)
store_index(store, DB_FILENAME, pages, false)
store.write page[:store_path], page[:output] store.write page[:store_path], page[:output]
true true
else else
@ -137,11 +144,11 @@ module Docs
page[:entries].present? page[:entries].present?
end end
def store_index(store, filename, index) def store_index(store, filename, index, read_write=true)
old_json = store.read(filename) || '{}' old_json = read_write && store.read(filename) || '{}'
new_json = index.to_json new_json = index.to_json
instrument "#{filename.remove('.json')}.doc", before: old_json, after: new_json instrument "#{filename.remove('.json')}.doc", before: old_json, after: new_json
store.write(filename, new_json) read_write && store.write(filename, new_json)
end end
def store_meta(store) def store_meta(store)

Loading…
Cancel
Save