diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index b68d3e6c..68777771 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -87,8 +87,15 @@ module Docs end def store_page(store, id) + index = EntryIndex.new + pages = PageDb.new + store.open(path) do 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] true else @@ -137,11 +144,11 @@ module Docs page[:entries].present? end - def store_index(store, filename, index) - old_json = store.read(filename) || '{}' + def store_index(store, filename, index, read_write=true) + old_json = read_write && store.read(filename) || '{}' new_json = index.to_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 def store_meta(store)