diff --git a/.gitignore b/.gitignore index 2a1a8aa..548131c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *~ *.pyc -test.debug +test.json test.tex test.dot *.log @@ -9,6 +9,7 @@ test.dot *.pdf examples/*.check examples/*.vcheck +examples/*.json test.rtf *.out test.html diff --git a/Makefile b/Makefile index e351da0..8679034 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ examples=$(wildcard examples/*.gamebook) -all: rtf pdf html debug png txt +all: rtf pdf html json png txt rtf: $(examples:.gamebook=.rtf) tex: $(examples:.gamebook=.tex) pdf: $(examples:.gamebook=.pdf) html: $(examples:.gamebook=.html) examples/gamebookformatplay.js \ examples/gamebookformat.css -debug: $(examples:.gamebook=.debug) +json: $(examples:.gamebook=.json) check: $(examples:.gamebook=.check) vcheck: $(examples:.gamebook=.vcheck) dot: $(examples:.gamebook=.dot) @@ -38,13 +38,13 @@ examples/gamebookformat.css: gamebookformat.css %.dot: %.gamebook *.py templates/dot/*.dot python2.7 ./buildexamplegamebook.py $< $@ -%.debug: %.gamebook *.py templates/debug/*.debug +%.json: %.gamebook *.py templates/json/*.json python2.7 ./buildexamplegamebook.py $< $@ -%.check: %.debug +%.check: %.json python2.7 ./checkgamebook.py $< > $@ || true -%.vcheck: %.debug +%.vcheck: %.json python2.7 ./checkgamebook.py -v $< > $@ || true %.txt: %.gamebook *.py templates/txt/*.txt @@ -58,12 +58,12 @@ examples/gamebookformat.css: gamebookformat.css test: unittest checkexpected templatejstest -expected: rtf tex html debug txt dot map check vcheck +expected: rtf tex html json txt dot map check vcheck $(RM) expected/* && \ - cp examples/*.{rtf,tex,html,debug,txt,dot,map,check,vcheck} \ + cp examples/*.{rtf,tex,html,json,txt,dot,map,check,vcheck} \ expected -checkexpected: clean rtf tex html debug dot txt check vcheck +checkexpected: clean rtf tex html json dot txt check vcheck diff -r -x "*.aux" -x "*.gamebook" -x "*.log" -x "*.out" -x "*.png" \ -x "*.pdf" -x .gitignore -x "*.js" -x "*.css" \ -x "*.options" -q examples expected @@ -88,7 +88,7 @@ templatejstest: clean: $(RM) examples/*rtf examples/*.html examples/*.tex \ - examples/*.txt examples/*.debug examples/*.check examples/*.log \ + examples/*.txt examples/*.json examples/*.check examples/*.log \ examples/*.pdf examples/*.out *~ examples/*~ *.pyc examples/*.vcheck \ examples/*.dot examples/*.aux examples/*.toc $(png) \ $(map) templates/*~ templates/*/*~ \ diff --git a/checkgamebook.py b/checkgamebook.py index 35990fd..67e01e4 100755 --- a/checkgamebook.py +++ b/checkgamebook.py @@ -33,8 +33,6 @@ import os.path import sys import json -USAGE = "usage: %prog [options] inputfile(s)... outputfile" - def find_section_nr_names(sections): section_nr_to_name = {} for section_name,section_contents in sections.iteritems(): @@ -118,7 +116,7 @@ if __name__ == '__main__': ap = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument('inputfile', metavar='debugfile', - help='input gamebook debug file (eg test.debug)') + help='input gamebook JSON file (eg test.json)') ap.add_argument('-v', '--verbose', action='store_true', dest='verbose', help='verbose output') diff --git a/examples/format.gamebook b/examples/format.gamebook index 79689a9..b4340e1 100644 --- a/examples/format.gamebook +++ b/examples/format.gamebook @@ -50,7 +50,7 @@ This is the format-specific HTML section. Now you [[good][win]]. * formatspecific :TXT: This is the format-specific TXT section. Now you [[good][win]]. -*formatspecific :DOT:RTF:DEBUG: +*formatspecific :DOT:RTF:JSON: This is the format-specific section for no other formats. Now you [[bad][lose]]. * good diff --git a/examples/trade.gamebook b/examples/trade.gamebook index c232d9d..2ab2489 100644 --- a/examples/trade.gamebook +++ b/examples/trade.gamebook @@ -19,7 +19,7 @@ You can also go to [[someotherplace]] but an angry troll is blocking your path and will only allow you to go there if you give it a [trade item]gold ring[/trade]. -* other :TXT:DEBUG:TEX:DOT:RTF: +* other :TXT:JSON:TEX:DOT:RTF: Now you have 50 less gold than you just had. You can go back to [[start]]. diff --git a/expected/bgg.debug b/expected/bgg.json similarity index 100% rename from expected/bgg.debug rename to expected/bgg.json diff --git a/expected/bgg.vcheck b/expected/bgg.vcheck index 8a7fcc8..251a218 100644 --- a/expected/bgg.vcheck +++ b/expected/bgg.vcheck @@ -1 +1 @@ -examples/bgg.debug: ending (death?) section found: end +examples/bgg.json: ending (death?) section found: end diff --git a/expected/codewords.debug b/expected/codewords.json similarity index 100% rename from expected/codewords.debug rename to expected/codewords.json diff --git a/expected/codewords.vcheck b/expected/codewords.vcheck index e9bd52e..3ea7a5c 100644 --- a/expected/codewords.vcheck +++ b/expected/codewords.vcheck @@ -1,2 +1,2 @@ -examples/codewords.debug: ending (death?) section found: the_end -examples/codewords.debug: ending (death?) section found: cheater +examples/codewords.json: ending (death?) section found: the_end +examples/codewords.json: ending (death?) section found: cheater diff --git a/expected/counters.debug b/expected/counters.json similarity index 100% rename from expected/counters.debug rename to expected/counters.json diff --git a/expected/counters.vcheck b/expected/counters.vcheck index e39c815..122312e 100644 --- a/expected/counters.vcheck +++ b/expected/counters.vcheck @@ -1 +1 @@ -examples/counters.debug: ending (death?) section found: death +examples/counters.json: ending (death?) section found: death diff --git a/expected/format.debug b/expected/format.json similarity index 100% rename from expected/format.debug rename to expected/format.json diff --git a/expected/format.vcheck b/expected/format.vcheck index 779036e..9ef92d6 100644 --- a/expected/format.vcheck +++ b/expected/format.vcheck @@ -1,2 +1,2 @@ -examples/format.debug: ending (death?) section found: good -examples/format.debug: ending (death?) section found: bad +examples/format.json: ending (death?) section found: good +examples/format.json: ending (death?) section found: bad diff --git a/expected/htmlbook.debug b/expected/htmlbook.json similarity index 100% rename from expected/htmlbook.debug rename to expected/htmlbook.json diff --git a/expected/htmlbook.vcheck b/expected/htmlbook.vcheck index 6ba92fe..ef285dc 100644 --- a/expected/htmlbook.vcheck +++ b/expected/htmlbook.vcheck @@ -1,2 +1,2 @@ -examples/htmlbook.debug: ending (death?) section found: second -examples/htmlbook.debug: ending (death?) section found: third +examples/htmlbook.json: ending (death?) section found: second +examples/htmlbook.json: ending (death?) section found: third diff --git a/expected/items.debug b/expected/items.json similarity index 100% rename from expected/items.debug rename to expected/items.json diff --git a/expected/items.vcheck b/expected/items.vcheck index 2b59b71..c124021 100644 --- a/expected/items.vcheck +++ b/expected/items.vcheck @@ -1 +1 @@ -examples/items.debug: ending (death?) section found: won +examples/items.json: ending (death?) section found: won diff --git a/expected/itemslist.debug b/expected/itemslist.json similarity index 100% rename from expected/itemslist.debug rename to expected/itemslist.json diff --git a/expected/itemslist.vcheck b/expected/itemslist.vcheck index 499a9a3..0aeb4f3 100644 --- a/expected/itemslist.vcheck +++ b/expected/itemslist.vcheck @@ -1 +1 @@ -examples/itemslist.debug: ending (death?) section found: won +examples/itemslist.json: ending (death?) section found: won diff --git a/expected/itemstaglist.check b/expected/itemstaglist.check index 57d8046..9cb8e38 100644 --- a/expected/itemstaglist.check +++ b/expected/itemstaglist.check @@ -1 +1 @@ -examples/itemstaglist.debug: No start section found. Cancelling checks. +examples/itemstaglist.json: No start section found. Cancelling checks. diff --git a/expected/itemstaglist.debug b/expected/itemstaglist.json similarity index 100% rename from expected/itemstaglist.debug rename to expected/itemstaglist.json diff --git a/expected/itemstaglist.vcheck b/expected/itemstaglist.vcheck index 57d8046..9cb8e38 100644 --- a/expected/itemstaglist.vcheck +++ b/expected/itemstaglist.vcheck @@ -1 +1 @@ -examples/itemstaglist.debug: No start section found. Cancelling checks. +examples/itemstaglist.json: No start section found. Cancelling checks. diff --git a/expected/letter.debug b/expected/letter.json similarity index 100% rename from expected/letter.debug rename to expected/letter.json diff --git a/expected/letter.vcheck b/expected/letter.vcheck index 0f66853..4a6b666 100644 --- a/expected/letter.vcheck +++ b/expected/letter.vcheck @@ -1 +1 @@ -examples/letter.debug: ending (death?) section found: start +examples/letter.json: ending (death?) section found: start diff --git a/expected/references.debug b/expected/references.json similarity index 100% rename from expected/references.debug rename to expected/references.json diff --git a/expected/references.vcheck b/expected/references.vcheck index 9f22468..47532b9 100644 --- a/expected/references.vcheck +++ b/expected/references.vcheck @@ -1,2 +1,2 @@ -examples/references.debug: ending (death?) section found: end -examples/references.debug: ending (death?) section found: altend +examples/references.json: ending (death?) section found: end +examples/references.json: ending (death?) section found: altend diff --git a/expected/trade.check b/expected/trade.check index bc01ff3..9c6078e 100644 --- a/expected/trade.check +++ b/expected/trade.check @@ -1 +1 @@ -examples/trade.debug: Could not reach section 'someotherplace' from start. +examples/trade.json: Could not reach section 'someotherplace' from start. diff --git a/expected/trade.debug b/expected/trade.json similarity index 100% rename from expected/trade.debug rename to expected/trade.json diff --git a/expected/trade.vcheck b/expected/trade.vcheck index 246887e..65a07ae 100644 --- a/expected/trade.vcheck +++ b/expected/trade.vcheck @@ -1,2 +1,2 @@ -examples/trade.debug: Could not reach section 'someotherplace' from start. -examples/trade.debug: ending (death?) section found: theend +examples/trade.json: Could not reach section 'someotherplace' from start. +examples/trade.json: ending (death?) section found: theend diff --git a/expected/unreachable.check b/expected/unreachable.check index a093105..a207fee 100644 --- a/expected/unreachable.check +++ b/expected/unreachable.check @@ -1,3 +1,3 @@ -examples/unreachable.debug: Could not reach section 'nothere' from start. -examples/unreachable.debug: Could not reach section 'nothereeither' from start. -examples/unreachable.debug: Could not reach section 'secondfake' from start. +examples/unreachable.json: Could not reach section 'nothere' from start. +examples/unreachable.json: Could not reach section 'nothereeither' from start. +examples/unreachable.json: Could not reach section 'secondfake' from start. diff --git a/expected/unreachable.debug b/expected/unreachable.json similarity index 100% rename from expected/unreachable.debug rename to expected/unreachable.json diff --git a/expected/unreachable.vcheck b/expected/unreachable.vcheck index e3f97b7..3a65760 100644 --- a/expected/unreachable.vcheck +++ b/expected/unreachable.vcheck @@ -1,7 +1,7 @@ -examples/unreachable.debug: Could not reach section 'nothere' from start. -examples/unreachable.debug: Could not reach section 'nothereeither' from start. -examples/unreachable.debug: Could not reach section 'secondfake' from start. -examples/unreachable.debug: ending (death?) section found: nothere -examples/unreachable.debug: ending (death?) section found: here -examples/unreachable.debug: ending (death?) section found: nothereeither -examples/unreachable.debug: ending (death?) section found: secondfake +examples/unreachable.json: Could not reach section 'nothere' from start. +examples/unreachable.json: Could not reach section 'nothereeither' from start. +examples/unreachable.json: Could not reach section 'secondfake' from start. +examples/unreachable.json: ending (death?) section found: nothere +examples/unreachable.json: ending (death?) section found: here +examples/unreachable.json: ending (death?) section found: nothereeither +examples/unreachable.json: ending (death?) section found: secondfake diff --git a/expected/withdemo.debug b/expected/withdemo.json similarity index 100% rename from expected/withdemo.debug rename to expected/withdemo.json diff --git a/expected/withdemo.vcheck b/expected/withdemo.vcheck index f427ace..5af294c 100644 --- a/expected/withdemo.vcheck +++ b/expected/withdemo.vcheck @@ -1 +1 @@ -examples/withdemo.debug: ending (death?) section found: theend +examples/withdemo.json: ending (death?) section found: theend diff --git a/expected/withmaps.debug b/expected/withmaps.json similarity index 100% rename from expected/withmaps.debug rename to expected/withmaps.json diff --git a/expected/withmaps.vcheck b/expected/withmaps.vcheck index de45ce3..c9fcc33 100644 --- a/expected/withmaps.vcheck +++ b/expected/withmaps.vcheck @@ -1 +1 @@ -examples/withmaps.debug: ending (death?) section found: end +examples/withmaps.json: ending (death?) section found: end diff --git a/expected/withoutdemo.check b/expected/withoutdemo.check index da76f01..2d20022 100644 --- a/expected/withoutdemo.check +++ b/expected/withoutdemo.check @@ -1 +1 @@ -examples/withoutdemo.debug: Could not reach section 'demoinfo' from start. +examples/withoutdemo.json: Could not reach section 'demoinfo' from start. diff --git a/expected/withoutdemo.debug b/expected/withoutdemo.json similarity index 100% rename from expected/withoutdemo.debug rename to expected/withoutdemo.json diff --git a/expected/withoutdemo.vcheck b/expected/withoutdemo.vcheck index cb4e290..2a37744 100644 --- a/expected/withoutdemo.vcheck +++ b/expected/withoutdemo.vcheck @@ -1,3 +1,3 @@ -examples/withoutdemo.debug: Could not reach section 'demoinfo' from start. -examples/withoutdemo.debug: ending (death?) section found: theend -examples/withoutdemo.debug: ending (death?) section found: altend +examples/withoutdemo.json: Could not reach section 'demoinfo' from start. +examples/withoutdemo.json: ending (death?) section found: theend +examples/withoutdemo.json: ending (death?) section found: altend diff --git a/formatgamebook.py b/formatgamebook.py index 4135526..7220934 100755 --- a/formatgamebook.py +++ b/formatgamebook.py @@ -55,7 +55,7 @@ OUTPUT_FORMATS = [ of('dot', 'Graphviz section flowchart', quote.no), of('html', 'HTML+JS playable in browser', quote.html), of('txt', 'Plain text', quote.no), - of('debug', 'Debug (JSON) Output', quote.js), + of('json', 'JSON', quote.js), ] def make_supported_formats_list_string(): diff --git a/readme.org b/readme.org index cd9c67a..b1a62a9 100644 --- a/readme.org +++ b/readme.org @@ -28,7 +28,7 @@ gamebook on paper or a screen (or for debugging it). | Graphviz DOT | .dot | Use with the [[http://www.graphviz.org][Graphviz]] dot tool to generate a flowchart graph of all sections in the gamebook. | | HTML | .html | Play gamebook in browser. | | Plain Text | .txt | Raw plain text without formatting. | -| Debug JSON | .debug | [[http://json.org][JSON-formatted]] debug output of gamebook contents. | +| JSON | .json | [[http://json.org][JSON-format]] for debugging | More to be added. Custom output formats or modifications to the default formats can easily be added. Use the *-t* command-line @@ -87,9 +87,9 @@ you like. ** Check Gamebook The included *checkgamebook.py* script can be used to run tests on a book and warn about things that do not look right. -To use it first generate a *debug* output file version of +To use it first generate a *json* output file version of the book, using the same flags (eg include-tags) as when -formatting the real book. Then run *checkgamebook.py bookname.debug*. +formatting the real book. Then run *checkgamebook.py bookname.json*. Currently only tests that all sections can be reached, in theory, from the *start* section. It only looks for existing references, and has no idea for instance if a locked door can never be diff --git a/templates/debug/add.debug b/templates/json/add.json similarity index 100% rename from templates/debug/add.debug rename to templates/json/add.json diff --git a/templates/debug/atleast.debug b/templates/json/atleast.json similarity index 100% rename from templates/debug/atleast.debug rename to templates/json/atleast.json diff --git a/templates/debug/auto.debug b/templates/json/auto.json similarity index 100% rename from templates/debug/auto.debug rename to templates/json/auto.json diff --git a/templates/debug/begin.debug b/templates/json/begin.json similarity index 100% rename from templates/debug/begin.debug rename to templates/json/begin.json diff --git a/templates/debug/collect.debug b/templates/json/collect.json similarity index 100% rename from templates/debug/collect.debug rename to templates/json/collect.json diff --git a/templates/debug/cost.debug b/templates/json/cost.json similarity index 100% rename from templates/debug/cost.debug rename to templates/json/cost.json diff --git a/templates/debug/count.debug b/templates/json/count.json similarity index 100% rename from templates/debug/count.debug rename to templates/json/count.json diff --git a/templates/debug/dec.debug b/templates/json/dec.json similarity index 100% rename from templates/debug/dec.debug rename to templates/json/dec.json diff --git a/templates/debug/drop.debug b/templates/json/drop.json similarity index 100% rename from templates/debug/drop.debug rename to templates/json/drop.json diff --git a/templates/debug/empty_section.debug b/templates/json/empty_section.json similarity index 100% rename from templates/debug/empty_section.debug rename to templates/json/empty_section.json diff --git a/templates/debug/end.debug b/templates/json/end.json similarity index 100% rename from templates/debug/end.debug rename to templates/json/end.json diff --git a/templates/debug/footnote.debug b/templates/json/footnote.json similarity index 100% rename from templates/debug/footnote.debug rename to templates/json/footnote.json diff --git a/templates/debug/found.debug b/templates/json/found.json similarity index 100% rename from templates/debug/found.debug rename to templates/json/found.json diff --git a/templates/debug/has.debug b/templates/json/has.json similarity index 100% rename from templates/debug/has.debug rename to templates/json/has.json diff --git a/templates/debug/hasnot.debug b/templates/json/hasnot.json similarity index 100% rename from templates/debug/hasnot.debug rename to templates/json/hasnot.json diff --git a/templates/debug/img.debug b/templates/json/img.json similarity index 100% rename from templates/debug/img.debug rename to templates/json/img.json diff --git a/templates/debug/inc.debug b/templates/json/inc.json similarity index 100% rename from templates/debug/inc.debug rename to templates/json/inc.json diff --git a/templates/debug/init.debug b/templates/json/init.json similarity index 100% rename from templates/debug/init.debug rename to templates/json/init.json diff --git a/templates/debug/introsection.debug b/templates/json/introsection.json similarity index 100% rename from templates/debug/introsection.debug rename to templates/json/introsection.json diff --git a/templates/debug/lessthan.debug b/templates/json/lessthan.json similarity index 100% rename from templates/debug/lessthan.debug rename to templates/json/lessthan.json diff --git a/templates/debug/min.debug b/templates/json/min.json similarity index 100% rename from templates/debug/min.debug rename to templates/json/min.json diff --git a/templates/debug/morethan.debug b/templates/json/morethan.json similarity index 100% rename from templates/debug/morethan.debug rename to templates/json/morethan.json diff --git a/templates/debug/named_section_ref.debug b/templates/json/named_section_ref.json similarity index 100% rename from templates/debug/named_section_ref.debug rename to templates/json/named_section_ref.json diff --git a/templates/debug/random.debug b/templates/json/random.json similarity index 100% rename from templates/debug/random.debug rename to templates/json/random.json diff --git a/templates/debug/section.debug b/templates/json/section.json similarity index 100% rename from templates/debug/section.debug rename to templates/json/section.json diff --git a/templates/debug/section_ref.debug b/templates/json/section_ref.json similarity index 100% rename from templates/debug/section_ref.debug rename to templates/json/section_ref.json diff --git a/templates/debug/sections_begin.debug b/templates/json/sections_begin.json similarity index 100% rename from templates/debug/sections_begin.debug rename to templates/json/sections_begin.json diff --git a/templates/debug/set.debug b/templates/json/set.json similarity index 100% rename from templates/debug/set.debug rename to templates/json/set.json diff --git a/templates/debug/text.debug b/templates/json/text.json similarity index 100% rename from templates/debug/text.debug rename to templates/json/text.json diff --git a/templates/debug/trade.debug b/templates/json/trade.json similarity index 100% rename from templates/debug/trade.debug rename to templates/json/trade.json diff --git a/templates/debug/xor.debug b/templates/json/xor.json similarity index 100% rename from templates/debug/xor.debug rename to templates/json/xor.json diff --git a/todo.org b/todo.org index 5c9e2ab..ef94df6 100644 --- a/todo.org +++ b/todo.org @@ -1,4 +1,4 @@ -* TODO [64/93] [68%] +* TODO [65/95] [68%] ** DONE Debug output ** DONE DOT output ** DONE LaTeX output @@ -83,7 +83,10 @@ CLOSED: [2014-09-23 Tue 23:10] ** DONE checkgamebook.py find unreachable sections CLOSED: [2014-09-23 Tue 23:10] -** TODO JavaScript improved design/code for what links to enable +** DONE Debug output should be called just JSON + CLOSED: [2014-09-24 Wed 21:36] +** TODO JavaScript improved design/code for what links to enable using JSON + Rewrite HTML player to generate HTML from JSON dynamically. Many strange things can happen when clicking one link changes something that should now enable or disable some link. Instead of the current hacks all links should be re-calculated every time something have been @@ -185,3 +188,5 @@ listed even if it is not tagged. Some tag that can be set on incomplete sections to trigger warnings as a reminder that the book is not done yet, and show you what sections remain to be written. +** TODO Generic MAP section numbers substitution script + Use generated MAP file to insert section numbers in any external file.