summary refs log tree commit diff stats
path: root/lib/packages/docutils/rstgen.nim
Commit message (Collapse)AuthorAgeFilesLines
* docgen: render 'interpreted text' the same as inline literals for markdown ↵Araq2019-01-111-3/+1
| | | | compat
* Don't prevent ',' from getting escaped in theindex.htmlKaushal Modi2018-09-281-3/+7
| | | | | | - Enable escaping of links in theindex.html - Fixes https://github.com/nim-lang/Nim/issues/9107. - Second part of the fix for https://github.com/nim-lang/Nim/issues/9097.
* nim doc: simplifiy index generationAraq2018-09-131-7/+10
|
* index generation for docgen knows about subdirectories; index knows about ↵Araq2018-09-131-35/+45
| | | | enum values; fixes import statement for runnableExamples
* even more strict isNil handling for strings/seqs in order to detect bugsAraq2018-08-221-16/+10
|
* WIP: disallow 'nil' for strings and seqsAndreas Rumpf2018-08-131-5/+4
|
* fixes more nil string bugsAraq2018-08-081-4/+3
|
* Better doc search (#8260)Ray Imber2018-07-201-4/+8
| | | | | | | | | | | | | | | | | | * Modified the doc generation to produce a custom data attribute to allow for better search functionality * Implemented fuzzy matching for the Nim Doc search instead of the simple regex match. * Fix to the WordBoundry state transition from code review with @Varriount. Also removed silly testing template that is no longer used. * Update fuzzysearch.nim * Update fuzzysearch.nim * Update fuzzysearch.nim * Update dochack.nim * Update dochack.nim
* removed global variable from rstgen.nimAndreas Rumpf2018-05-271-5/+8
|
* Rstgen/xml tree fixes (#7823)Dominik Picheta2018-05-231-29/+34
| | | | | | | | | | | | | * Don't prefix lang names with "lang" in rstgen. * Implements ability to render xmltree w/o \n. Fixes <> for `data-*` attrs. * Various rstgen fixes. * Fixes security vulnerabilities due to not escaping some code. * Adds <video> support and improve `.. image:: ` directive. * Adds comment as requested.
* RST package: don't use obsolete toLower procAndreas Rumpf2018-04-291-1/+1
|
* docutils: make ':test:' work without argumentAndreas Rumpf2018-04-151-3/+6
|
* the documentation generator now supports ':test:' for the testing of test ↵Araq2017-11-281-5/+19
| | | | snippets
* the documentation generator now supports system.runnableExamplesAraq2017-11-261-1/+1
|
* Add possibility to get language class to listings (#6705)Silvio2017-11-081-2/+2
| | | | Add the possibility to add class `lang<Name>` to code listings. Needed for restricting `run` to nim code (see https://github.com/nim-lang/nimforum/pull/111 )
* fixes #6609; 'if' expressions support multiple statements; minor breaking changeAraq2017-11-051-1/+2
|
* Remove expr/stmt (#5857)Arne Döring2017-07-251-2/+2
|
* Make countLines() the same as len(splitLines(s)) (#5470)Simon Krauter2017-03-031-1/+1
| | | | | The result of countLines() is now increased by 1 compared to the old version. Fixes #5460.
* docgen: working search featureAraq2016-09-091-3/+3
|
* generated theindex.html is valid htmlAraq2016-09-091-10/+21
|
* Merge pull request #3831 from ephja/nimrod-to-nimAndreas Rumpf2016-02-061-2/+2
|\ | | | | nimrod -> nim
| * nimrod -> nimErik Johansson Andersson2016-02-051-2/+2
| |
* | RST: Output <object> for SVG images in HTMLFelix Krause2016-02-021-7/+17
|/
* Made docgen emit valid XML by defaultFelix Krause2016-01-111-2/+2
|
* udpated the compiler and tester to use getOrDefaultAraq2015-10-131-10/+13
|
* Fix for image directive with periodssingularperturbation2015-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saw in https://github.com/nim-lang/nimforum/issues/41 that there was an issue in rendering inline images. Traced back through rstgen and found that it was not counting something like: `.. image:: http://i.imgur.com/oCem13Y.png` as valid since it contained a period, and this wasn't in the set of valid characters, so the empty string is returned by default. Added a period to the allowable characters, and now renders correctly. Test case: ``` import rst, rstgen, strtabs var docConfig: StringTableRef docConfig = rstgen.defaultConfig() docConfig["doc.smiley_format"] = "/images/smilieys/$1.png" proc rstToHtml(content: string): string = result = rstgen.rstToHtml(content, {roSupportSmilies,roSupportMarkdown}, docConfig) var a: string = rstToHtml(".. image:: http://i.imgur.com/oCem13Y.png") echo a ```
* documentation generator emits configurable html for code listingsAraq2015-07-141-6/+14
|
* lib/packages/docutils - Dropped 'T' from typespdw2015-06-041-60/+61
|
* Turn some test outputs into actual testsOleh Prypin2015-04-211-3/+4
|
* Don't run non-test code when defined(testing)Oleh Prypin2015-04-211-1/+1
|
* fixes #2476Araq2015-04-191-132/+132
|
* rstgen: Unique reference names in TOCdef2015-03-131-1/+8
| | | | | - Fixes #2269 - Keeps track of higher level section to create unique reference names
* Replaced deprecated repeatStr() with repeat().Hans Raaf2015-03-041-2/+2
|
* Replaced deprecated repeatChar() with repeat() or spaces().Hans Raaf2015-03-041-1/+1
|
* Fix typosFederico Ceratto2015-02-151-1/+1
|
* Replace other common expressions with defined variableDustin Lacewell2015-01-121-2/+2
|
* Add named anchor links to procs in the documentation indexDustin Lacewell2015-01-121-2/+4
|
* Improved nimdoc styling.Nick Greenfield2014-12-191-2/+2
| | | | | | | This updates the inlined CSS in nimdoc.cfg, adds several helper classes (and a few divs) to the generated HTML (some in nimdoc.cfg, one in rstgen.nim), and tweaks the anchor linking scheme for headers in rstgen.nim.
* Moved smiliey format to config hash table.Dominik Picheta2014-12-041-5/+3
|
* smileys configurable; safer image attribute handlingAraq2014-11-291-18/+24
|
* fixes #1055Araq2014-11-161-4/+4
|
* Merge branch 'pr_adds_code_directive_to_rst' into ↵Grzegorz Adam Hankiewicz2014-11-031-14/+103
|\ | | | | | | | | | | | | | | | | pr_bigbreak_adds_code_directive_to_rst Conflicts: doc/tut2.txt lib/packages/docutils/rstgen.nim lib/system.nim
| * Fixes line numbering.Grzegorz Adam Hankiewicz2014-10-021-1/+1
| |
| * Handles :file: option for code blocks to avoid warnings.Grzegorz Adam Hankiewicz2014-07-261-0/+7
| |
| * Adds support for the ``.. code::`` rst directive.Grzegorz Adam Hankiewicz2014-07-191-14/+96
| | | | | | | | | | | | This modifies the existing ``.. code-block::`` to be treated as spec extension with a specific default language syntax. Also implements line numbering.
* | updated the compiler to use the new symbol namesAraq2014-08-281-10/+10
| |
* | renamefestAraq2014-08-231-6/+6
| |
* | the big renamefest: first stepsAraq2014-08-221-6/+6
| |
* | Escapes properly code blocks without highlite support.Grzegorz Adam Hankiewicz2014-07-281-1/+1
|/
* Computes TIndexEntry hash without temporary strings.Grzegorz Adam Hankiewicz2014-05-241-5/+6
|
apshot.initial_font = love.graphics.getFont() end function App.undo_initialize() love.graphics.setFont(Love_snapshot.initial_font) end function App.run_tests_and_initialize() App.load() Test_errors = {} App.run_tests() if #Test_errors > 0 then local error_message = '' if Warning_before_tests then error_message = Warning_before_tests..'\n\n' end error_message = error_message .. ('There were %d test failures:\n%s'):format(#Test_errors, table.concat(Test_errors)) error(error_message) end App.disable_tests() App.initialize_globals() App.initialize(love.arg.parseGameArguments(arg), arg) end function App.run_tests() local sorted_names = {} for name,binding in pairs(_G) do if name:find('test_') == 1 then table.insert(sorted_names, name) end end table.sort(sorted_names) for _,name in ipairs(sorted_names) do App.initialize_for_test() --? print('=== '..name) --? _G[name]() xpcall(_G[name], function(err) prepend_debug_info_to_test_failure(name, err) end) end -- clean up all test methods for _,name in ipairs(sorted_names) do _G[name] = nil end end function App.initialize_for_test() App.screen.init{width=100, height=50} App.screen.contents = {} -- clear screen App.filesystem = {} App.source_dir = '' App.current_dir = '' App.save_dir = '' App.fake_keys_pressed = {} App.fake_mouse_state = {x=-1, y=-1} App.initialize_globals() end -- App.screen.resize and App.screen.move seem like better names than -- love.window.setMode and love.window.setPosition respectively. They'll -- be side-effect-free during tests, and they'll save their results in -- attributes of App.screen for easy access. App.screen={} -- Use App.screen.init in tests to initialize the fake screen. function App.screen.init(dims) App.screen.width = dims.width App.screen.height = dims.height end function App.screen.resize(width, height, flags) App.screen.width = width App.screen.height = height App.screen.flags = flags end function App.screen.size() return App.screen.width, App.screen.height, App.screen.flags end function App.screen.move(x,y, displayindex) App.screen.x = x App.screen.y = y App.screen.displayindex = displayindex end function App.screen.position() return App.screen.x, App.screen.y, App.screen.displayindex end -- If you use App.screen.print instead of love.graphics.print, -- tests will be able to check what was printed using App.screen.check below. -- -- One drawback of this approach: the y coordinate used depends on font size, -- which feels brittle. function App.screen.print(msg, x,y) local screen_row = 'y'..tostring(y) --? print('drawing "'..msg..'" at y '..tostring(y)) local screen = App.screen if screen.contents[screen_row] == nil then screen.contents[screen_row] = {} for i=0,screen.width-1 do screen.contents[screen_row][i] = '' end end if x < screen.width then screen.contents[screen_row][x] = msg end end function App.screen.check(y, expected_contents, msg) --? print('checking for "'..expected_contents..'" at y '..tostring(y)) local screen_row = 'y'..tostring(y) local contents = '' if App.screen.contents[screen_row] == nil then error('no text at y '..tostring(y)) end for i,s in ipairs(App.screen.contents[screen_row]) do contents = contents..s end check_eq(contents, expected_contents, msg) end -- If you access the time using App.get_time instead of love.timer.getTime, -- tests will be able to move the time back and forwards as needed using -- App.wait_fake_time below. App.time = 1 function App.get_time() return App.time end function App.wait_fake_time(t) App.time = App.time + t end function App.width(text) return love.graphics.getFont():getWidth(text) end -- If you access the clipboard using App.get_clipboard and App.set_clipboard -- instead of love.system.getClipboardText and love.system.setClipboardText -- respectively, tests will be able to manipulate the clipboard by -- reading/writing App.clipboard. App.clipboard = '' function App.get_clipboard() return App.clipboard end function App.set_clipboard(s) App.clipboard = s end -- In tests I mostly send chords all at once to the keyboard handlers. -- However, you'll occasionally need to check if a key is down outside a handler. -- If you use App.key_down instead of love.keyboard.isDown, tests will be able to -- simulate keypresses using App.fake_key_press and App.fake_key_release -- below. This isn't very realistic, though, and it's up to tests to -- orchestrate key presses that correspond to the handlers they invoke. App.fake_keys_pressed = {} function App.key_down(key) return App.fake_keys_pressed[key] end function App.fake_key_press(key) App.fake_keys_pressed[key] = true end function App.fake_key_release(key) App.fake_keys_pressed[key] = nil end -- Tests mostly will invoke mouse handlers directly. However, you'll -- occasionally need to check if a mouse button is down outside a handler. -- If you use App.mouse_down instead of love.mouse.isDown, tests will be able to -- simulate mouse clicks using App.fake_mouse_press and App.fake_mouse_release -- below. This isn't very realistic, though, and it's up to tests to -- orchestrate presses that correspond to the handlers they invoke. App.fake_mouse_state = {x=-1, y=-1} -- x,y always set function App.mouse_move(x,y) App.fake_mouse_state.x = x App.fake_mouse_state.y = y end function App.mouse_down(mouse_button) return App.fake_mouse_state[mouse_button] end function App.mouse_x() return App.fake_mouse_state.x end function App.mouse_y() return App.fake_mouse_state.y end function App.fake_mouse_press(x,y, mouse_button) App.fake_mouse_state.x = x App.fake_mouse_state.y = y App.fake_mouse_state[mouse_button] = true end function App.fake_mouse_release(x,y, mouse_button) App.fake_mouse_state.x = x App.fake_mouse_state.y = y App.fake_mouse_state[mouse_button] = nil end -- If you use App.open_for_reading and App.open_for_writing instead of other -- various Lua and LÖVE helpers, tests will be able to check the results of -- file operations inside the App.filesystem table. function App.open_for_reading(filename) if App.filesystem[filename] then return { lines = function(self) return App.filesystem[filename]:gmatch('[^\n]+') end, read = function(self) return App.filesystem[filename] end, close = function(self) end, } end end function App.read_file(filename) return App.filesystem[filename] end function App.open_for_writing(filename) App.filesystem[filename] = '' return { write = function(self, s) App.filesystem[filename] = App.filesystem[filename]..s end, close = function(self) end, } end function App.write_file(filename, contents) App.filesystem[filename] = contents return --[[status]] true end function App.mkdir(dirname) -- nothing in test mode end function App.remove(filename) App.filesystem[filename] = nil end -- Some helpers to trigger an event and then refresh the screen. Akin to one -- iteration of the event loop. -- all textinput events are also keypresses -- TODO: handle chords of multiple keys function App.run_after_textinput(t) App.keypressed(t) App.textinput(t) App.keyreleased(t) App.screen.contents = {} App.draw() end -- not all keys are textinput -- TODO: handle chords of multiple keys function App.run_after_keychord(chord) App.keychord_press(chord) App.keyreleased(chord) App.screen.contents = {} App.draw() end function App.run_after_mouse_click(x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) App.mousepressed(x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) App.mousereleased(x,y, mouse_button) App.screen.contents = {} App.draw() end function App.run_after_mouse_press(x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) App.mousepressed(x,y, mouse_button) App.screen.contents = {} App.draw() end function App.run_after_mouse_release(x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) App.mousereleased(x,y, mouse_button) App.screen.contents = {} App.draw() end -- miscellaneous internal helpers function App.color(color) love.graphics.setColor(color.r, color.g, color.b, color.a) end -- prepend file/line/test function prepend_debug_info_to_test_failure(test_name, err) local err_without_line_number = err:gsub('^[^:]*:[^:]*: ', '') local stack_trace = debug.traceback('', --[[stack frame]]5) local file_and_line_number = stack_trace:gsub('stack traceback:\n', ''):gsub(': .*', '') local full_error = file_and_line_number..':'..test_name..' -- '..err_without_line_number --? local full_error = file_and_line_number..':'..test_name..' -- '..err_without_line_number..'\t\t'..stack_trace:gsub('\n', '\n\t\t') table.insert(Test_errors, full_error) end nativefs = require 'nativefs' local Keys_down = {} -- call this once all tests are run -- can't run any tests after this function App.disable_tests() -- have LÖVE delegate all handlers to App if they exist -- make sure to late-bind handlers like LÖVE's defaults do for name in pairs(love.handlers) do if App[name] then -- love.keyboard.isDown doesn't work on Android, so emulate it using -- keypressed and keyreleased events if name == 'keypressed' then love.handlers[name] = function(key, scancode, isrepeat) Keys_down[key] = true return App.keypressed(key, scancode, isrepeat) end elseif name == 'keyreleased' then love.handlers[name] = function(key, scancode) Keys_down[key] = nil return App.keyreleased(key, scancode) end else love.handlers[name] = function(...) App[name](...) end end end end -- test methods are disallowed outside tests App.run_tests = nil App.disable_tests = nil App.screen.init = nil App.filesystem = nil App.time = nil App.run_after_textinput = nil App.run_after_keychord = nil App.keypress = nil App.keyrelease = nil App.run_after_mouse_click = nil App.run_after_mouse_press = nil App.run_after_mouse_release = nil App.fake_keys_pressed = nil App.fake_key_press = nil App.fake_key_release = nil App.fake_mouse_state = nil App.fake_mouse_press = nil App.fake_mouse_release = nil -- other methods dispatch to real hardware App.screen.resize = love.window.setMode App.screen.size = love.window.getMode App.screen.move = love.window.setPosition App.screen.position = love.window.getPosition App.screen.print = love.graphics.print App.open_for_reading = function(filename) local result = nativefs.newFile(filename) local ok, err = result:open('r') if ok then return result else return ok, err end end App.read_file = function(path) if not is_absolute_path(path) then return --[[status]] false, 'Please use an unambiguous absolute path.' end local f, err = App.open_for_reading(path) if err then return --[[status]] false, err end local contents = f:read() f:close() return contents end App.open_for_writing = function(filename) local result = nativefs.newFile(filename) local ok, err = result:open('w') if ok then return result else return ok, err end end App.write_file = function(path, contents) if not is_absolute_path(path) then return --[[status]] false, 'Please use an unambiguous absolute path.' end local f, err = App.open_for_writing(path) if err then return --[[status]] false, err end f:write(contents) f:close() return --[[status]] true end App.files = nativefs.getDirectoryItems App.file_info = nativefs.getInfo App.mkdir = nativefs.createDirectory App.remove = nativefs.remove App.source_dir = love.filesystem.getSource()..'/' -- '/' should work even on Windows App.current_dir = nativefs.getWorkingDirectory()..'/' App.save_dir = love.filesystem.getSaveDirectory()..'/' App.get_time = love.timer.getTime App.get_clipboard = love.system.getClipboardText App.set_clipboard = love.system.setClipboardText App.key_down = function(key) return Keys_down[key] end App.mouse_move = love.mouse.setPosition App.mouse_down = love.mouse.isDown App.mouse_x = love.mouse.getX App.mouse_y = love.mouse.getY end