gitlab-pygments.rb 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/README.md +91 -0
- data/Rakefile +78 -0
- data/bench.rb +22 -0
- data/cache-lexers.rb +8 -0
- data/lexers +0 -0
- data/lib/pygments/lexer.rb +148 -0
- data/lib/pygments/mentos.py +344 -0
- data/lib/pygments/popen.rb +389 -0
- data/lib/pygments/version.rb +3 -0
- data/lib/pygments.rb +8 -0
- data/pygments.rb.gemspec +24 -0
- data/test/test_data.c +2581 -0
- data/test/test_data.py +514 -0
- data/test/test_data_generated +2582 -0
- data/test/test_pygments.rb +276 -0
- data/vendor/custom_formatters/gitlab.py +171 -0
- data/vendor/custom_lexers/github.py +362 -0
- data/vendor/pygments-main/AUTHORS +115 -0
- data/vendor/pygments-main/CHANGES +762 -0
- data/vendor/pygments-main/LICENSE +25 -0
- data/vendor/pygments-main/MANIFEST.in +6 -0
- data/vendor/pygments-main/Makefile +59 -0
- data/vendor/pygments-main/REVISION +1 -0
- data/vendor/pygments-main/TODO +15 -0
- data/vendor/pygments-main/docs/generate.py +472 -0
- data/vendor/pygments-main/docs/pygmentize.1 +94 -0
- data/vendor/pygments-main/docs/src/api.txt +270 -0
- data/vendor/pygments-main/docs/src/authors.txt +5 -0
- data/vendor/pygments-main/docs/src/changelog.txt +5 -0
- data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
- data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
- data/vendor/pygments-main/docs/src/filters.txt +42 -0
- data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
- data/vendor/pygments-main/docs/src/formatters.txt +48 -0
- data/vendor/pygments-main/docs/src/index.txt +69 -0
- data/vendor/pygments-main/docs/src/installation.txt +71 -0
- data/vendor/pygments-main/docs/src/integrate.txt +43 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -0
- data/vendor/pygments-main/docs/src/lexers.txt +67 -0
- data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
- data/vendor/pygments-main/docs/src/plugins.txt +93 -0
- data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
- data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
- data/vendor/pygments-main/docs/src/styles.txt +143 -0
- data/vendor/pygments-main/docs/src/tokens.txt +349 -0
- data/vendor/pygments-main/docs/src/unicode.txt +49 -0
- data/vendor/pygments-main/external/markdown-processor.py +67 -0
- data/vendor/pygments-main/external/moin-parser.py +112 -0
- data/vendor/pygments-main/external/pygments.bashcomp +38 -0
- data/vendor/pygments-main/external/rst-directive-old.py +77 -0
- data/vendor/pygments-main/external/rst-directive.py +83 -0
- data/vendor/pygments-main/ez_setup.py +276 -0
- data/vendor/pygments-main/pygmentize +7 -0
- data/vendor/pygments-main/pygments/__init__.py +91 -0
- data/vendor/pygments-main/pygments/cmdline.py +433 -0
- data/vendor/pygments-main/pygments/console.py +74 -0
- data/vendor/pygments-main/pygments/filter.py +74 -0
- data/vendor/pygments-main/pygments/filters/__init__.py +357 -0
- data/vendor/pygments-main/pygments/formatter.py +92 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
- data/vendor/pygments-main/pygments/formatters/html.py +750 -0
- data/vendor/pygments-main/pygments/formatters/img.py +553 -0
- data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
- data/vendor/pygments-main/pygments/formatters/other.py +117 -0
- data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
- data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
- data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
- data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
- data/vendor/pygments-main/pygments/lexer.py +697 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +229 -0
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
- data/vendor/pygments-main/pygments/lexers/github.py +362 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +361 -0
- data/vendor/pygments-main/pygments/lexers/special.py +100 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +1631 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
- data/vendor/pygments-main/pygments/lexers/web.py +2864 -0
- data/vendor/pygments-main/pygments/plugin.py +74 -0
- data/vendor/pygments-main/pygments/scanner.py +104 -0
- data/vendor/pygments-main/pygments/style.py +117 -0
- data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
- data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
- data/vendor/pygments-main/pygments/styles/borland.py +51 -0
- data/vendor/pygments-main/pygments/styles/bw.py +49 -0
- data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
- data/vendor/pygments-main/pygments/styles/default.py +73 -0
- data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
- data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
- data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
- data/vendor/pygments-main/pygments/styles/manni.py +75 -0
- data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
- data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
- data/vendor/pygments-main/pygments/styles/native.py +65 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
- data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
- data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
- data/vendor/pygments-main/pygments/styles/tango.py +141 -0
- data/vendor/pygments-main/pygments/styles/trac.py +63 -0
- data/vendor/pygments-main/pygments/styles/vim.py +63 -0
- data/vendor/pygments-main/pygments/styles/vs.py +38 -0
- data/vendor/pygments-main/pygments/token.py +195 -0
- data/vendor/pygments-main/pygments/unistring.py +130 -0
- data/vendor/pygments-main/pygments/util.py +232 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -0
- data/vendor/pygments-main/scripts/epydoc.css +280 -0
- data/vendor/pygments-main/scripts/find_codetags.py +205 -0
- data/vendor/pygments-main/scripts/find_error.py +171 -0
- data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
- data/vendor/pygments-main/scripts/pylintrc +301 -0
- data/vendor/pygments-main/scripts/reindent.py +291 -0
- data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
- data/vendor/pygments-main/setup.cfg +6 -0
- data/vendor/pygments-main/setup.py +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
- data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
- data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
- data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
- data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
- data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
- data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
- data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
- data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
- data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
- data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
- data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
- data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
- data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
- data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
- data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
- data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
- data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
- data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
- data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
- data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
- data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
- data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
- data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
- data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
- data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
- data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +40 -0
- data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
- data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
- data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
- data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
- data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
- data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
- data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
- data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
- data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
- data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
- data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
- data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
- data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
- data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
- data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
- data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
- data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
- data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
- data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
- data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
- data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
- data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
- data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
- data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
- data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
- data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
- data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
- data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
- data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
- data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
- data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
- data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
- data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
- data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
- data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
- data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
- data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
- data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
- data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
- data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
- data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
- data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
- data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
- data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
- data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +27 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
- data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
- data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
- data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
- data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
- data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
- data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +25 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
- data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
- data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
- data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
- data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
- data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
- data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
- data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
- data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
- data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
- data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
- data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
- data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
- data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
- data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
- data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
- data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
- data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
- data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
- data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
- data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
- data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
- data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
- data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
- data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
- data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
- data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
- data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
- data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +119 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
- data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
- data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
- data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
- data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
- data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
- data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
- data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
- data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
- data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
- data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
- data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
- data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
- data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
- data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
- data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
- data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
- data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
- data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
- data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
- data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
- data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
- data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
- data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
- data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
- data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
- data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
- data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
- data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
- data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
- data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
- data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
- data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
- data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
- data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
- data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
- data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
- data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -0
- data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
- data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
- data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
- data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
- data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
- data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
- data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
- data/vendor/pygments-main/tests/old_run.py +138 -0
- data/vendor/pygments-main/tests/run.py +48 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/test_basic_api.py +294 -0
- data/vendor/pygments-main/tests/test_clexer.py +31 -0
- data/vendor/pygments-main/tests/test_cmdline.py +105 -0
- data/vendor/pygments-main/tests/test_examplefiles.py +97 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
- data/vendor/pygments-main/tests/test_perllexer.py +137 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
- data/vendor/pygments-main/tests/test_token.py +46 -0
- data/vendor/pygments-main/tests/test_using_api.py +40 -0
- data/vendor/pygments-main/tests/test_util.py +116 -0
- data/vendor/simplejson/.gitignore +10 -0
- data/vendor/simplejson/.travis.yml +5 -0
- data/vendor/simplejson/CHANGES.txt +291 -0
- data/vendor/simplejson/LICENSE.txt +19 -0
- data/vendor/simplejson/MANIFEST.in +5 -0
- data/vendor/simplejson/README.rst +19 -0
- data/vendor/simplejson/conf.py +179 -0
- data/vendor/simplejson/index.rst +628 -0
- data/vendor/simplejson/scripts/make_docs.py +18 -0
- data/vendor/simplejson/setup.py +104 -0
- data/vendor/simplejson/simplejson/__init__.py +510 -0
- data/vendor/simplejson/simplejson/_speedups.c +2745 -0
- data/vendor/simplejson/simplejson/decoder.py +425 -0
- data/vendor/simplejson/simplejson/encoder.py +567 -0
- data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
- data/vendor/simplejson/simplejson/scanner.py +77 -0
- data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
- data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
- data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
- data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
- data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
- data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
- data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
- data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
- data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
- data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
- data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
- data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
- data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
- data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
- data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
- data/vendor/simplejson/simplejson/tool.py +39 -0
- metadata +492 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (c) 2006-2011 by the respective authors (see AUTHORS file).
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are
|
6
|
+
met:
|
7
|
+
|
8
|
+
* Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
* Redistributions in binary form must reproduce the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
13
|
+
documentation and/or other materials provided with the distribution.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
16
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
17
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
18
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
19
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
20
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Makefile for Pygments
|
3
|
+
# ~~~~~~~~~~~~~~~~~~~~~
|
4
|
+
#
|
5
|
+
# Combines scripts for common tasks.
|
6
|
+
#
|
7
|
+
# :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
|
8
|
+
# :license: BSD, see LICENSE for details.
|
9
|
+
#
|
10
|
+
|
11
|
+
PYTHON ?= python
|
12
|
+
|
13
|
+
export PYTHONPATH = $(shell echo "$$PYTHONPATH"):$(shell python -c 'import os; print ":".join(os.path.abspath(line.strip()) for line in file("PYTHONPATH"))' 2>/dev/null)
|
14
|
+
|
15
|
+
.PHONY: all check clean clean-pyc codetags docs mapfiles \
|
16
|
+
pylint reindent test test-coverage
|
17
|
+
|
18
|
+
all: clean-pyc check test
|
19
|
+
|
20
|
+
check:
|
21
|
+
@$(PYTHON) scripts/detect_missing_analyse_text.py || true
|
22
|
+
@$(PYTHON) scripts/check_sources.py -i build -i dist -i pygments/lexers/_mapping.py \
|
23
|
+
-i docs/build -i pygments/formatters/_mapping.py -i pygments/unistring.py \
|
24
|
+
-i pygments/lexers/_vimbuiltins.py
|
25
|
+
|
26
|
+
clean: clean-pyc
|
27
|
+
-rm -rf build
|
28
|
+
-rm -f codetags.html
|
29
|
+
|
30
|
+
clean-pyc:
|
31
|
+
find . -name '*.pyc' -exec rm -f {} +
|
32
|
+
find . -name '*.pyo' -exec rm -f {} +
|
33
|
+
find . -name '*~' -exec rm -f {} +
|
34
|
+
|
35
|
+
codetags:
|
36
|
+
@$(PYTHON) scripts/find_codetags.py -i tests/examplefiles -i scripts/pylintrc \
|
37
|
+
-i scripts/find_codetags.py -o codetags.html .
|
38
|
+
|
39
|
+
docs: docs/build
|
40
|
+
|
41
|
+
docs/build: docs/src/*.txt
|
42
|
+
$(PYTHON) docs/generate.py html docs/build $?
|
43
|
+
touch docs/build
|
44
|
+
|
45
|
+
mapfiles:
|
46
|
+
(cd pygments/lexers; $(PYTHON) _mapping.py)
|
47
|
+
(cd pygments/formatters; $(PYTHON) _mapping.py)
|
48
|
+
|
49
|
+
pylint:
|
50
|
+
@pylint --rcfile scripts/pylintrc pygments
|
51
|
+
|
52
|
+
reindent:
|
53
|
+
@$(PYTHON) scripts/reindent.py -r -B .
|
54
|
+
|
55
|
+
test:
|
56
|
+
@$(PYTHON) tests/run.py $(TESTS)
|
57
|
+
|
58
|
+
test-coverage:
|
59
|
+
@$(PYTHON) tests/run.py -C $(TESTS)
|
@@ -0,0 +1 @@
|
|
1
|
+
5cc94956e233
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Todo
|
2
|
+
====
|
3
|
+
|
4
|
+
- suggested new lexers
|
5
|
+
* IPython sessions
|
6
|
+
|
7
|
+
- lexers that need work:
|
8
|
+
* review perl lexer (numerous bugs, but so far no one had complaints ;)
|
9
|
+
* readd property support for C# lexer? that is, find a regex that doesn't
|
10
|
+
backtrack to death...
|
11
|
+
* add support for function name highlighting to C++ lexer
|
12
|
+
|
13
|
+
- allow "overlay" token types to highlight specials: nth line, a word etc.
|
14
|
+
|
15
|
+
- pygmentize option presets, more sophisticated method to output styles?
|
@@ -0,0 +1,472 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
"""
|
4
|
+
Generate Pygments Documentation
|
5
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
6
|
+
|
7
|
+
Generates a bunch of html files containing the documentation.
|
8
|
+
|
9
|
+
:copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
|
10
|
+
:license: BSD, see LICENSE for details.
|
11
|
+
"""
|
12
|
+
|
13
|
+
import os
|
14
|
+
import sys
|
15
|
+
from datetime import datetime
|
16
|
+
from cgi import escape
|
17
|
+
|
18
|
+
from docutils import nodes
|
19
|
+
from docutils.parsers.rst import directives
|
20
|
+
from docutils.core import publish_parts
|
21
|
+
from docutils.writers import html4css1
|
22
|
+
|
23
|
+
from jinja2 import Template
|
24
|
+
|
25
|
+
# try to use the right Pygments to build the docs
|
26
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
27
|
+
|
28
|
+
from pygments import highlight, __version__
|
29
|
+
from pygments.lexers import get_lexer_by_name
|
30
|
+
from pygments.formatters import HtmlFormatter
|
31
|
+
|
32
|
+
|
33
|
+
LEXERDOC = '''
|
34
|
+
`%s`
|
35
|
+
%s
|
36
|
+
:Short names: %s
|
37
|
+
:Filename patterns: %s
|
38
|
+
:Mimetypes: %s
|
39
|
+
|
40
|
+
'''
|
41
|
+
|
42
|
+
def generate_lexer_docs():
|
43
|
+
from pygments.lexers import LEXERS
|
44
|
+
|
45
|
+
out = []
|
46
|
+
|
47
|
+
modules = {}
|
48
|
+
moduledocstrings = {}
|
49
|
+
for classname, data in sorted(LEXERS.iteritems(), key=lambda x: x[0]):
|
50
|
+
module = data[0]
|
51
|
+
mod = __import__(module, None, None, [classname])
|
52
|
+
cls = getattr(mod, classname)
|
53
|
+
if not cls.__doc__:
|
54
|
+
print "Warning: %s does not have a docstring." % classname
|
55
|
+
modules.setdefault(module, []).append((
|
56
|
+
classname,
|
57
|
+
cls.__doc__,
|
58
|
+
', '.join(data[2]) or 'None',
|
59
|
+
', '.join(data[3]).replace('*', '\\*').replace('_', '\\') or 'None',
|
60
|
+
', '.join(data[4]) or 'None'))
|
61
|
+
if module not in moduledocstrings:
|
62
|
+
moduledocstrings[module] = mod.__doc__
|
63
|
+
|
64
|
+
for module, lexers in sorted(modules.iteritems(), key=lambda x: x[0]):
|
65
|
+
heading = moduledocstrings[module].splitlines()[4].strip().rstrip('.')
|
66
|
+
out.append('\n' + heading + '\n' + '-'*len(heading) + '\n')
|
67
|
+
for data in lexers:
|
68
|
+
out.append(LEXERDOC % data)
|
69
|
+
return ''.join(out).decode('utf-8')
|
70
|
+
|
71
|
+
def generate_formatter_docs():
|
72
|
+
from pygments.formatters import FORMATTERS
|
73
|
+
|
74
|
+
out = []
|
75
|
+
for cls, data in sorted(FORMATTERS.iteritems(),
|
76
|
+
key=lambda x: x[0].__name__):
|
77
|
+
heading = cls.__name__
|
78
|
+
out.append('`' + heading + '`\n' + '-'*(2+len(heading)) + '\n')
|
79
|
+
out.append(cls.__doc__)
|
80
|
+
out.append('''
|
81
|
+
:Short names: %s
|
82
|
+
:Filename patterns: %s
|
83
|
+
|
84
|
+
|
85
|
+
''' % (', '.join(data[1]) or 'None', ', '.join(data[2]).replace('*', '\\*') or 'None'))
|
86
|
+
return ''.join(out).decode('utf-8')
|
87
|
+
|
88
|
+
def generate_filter_docs():
|
89
|
+
from pygments.filters import FILTERS
|
90
|
+
|
91
|
+
out = []
|
92
|
+
for name, cls in FILTERS.iteritems():
|
93
|
+
out.append('''
|
94
|
+
`%s`
|
95
|
+
%s
|
96
|
+
:Name: %s
|
97
|
+
''' % (cls.__name__, cls.__doc__, name))
|
98
|
+
return ''.join(out).decode('utf-8')
|
99
|
+
|
100
|
+
def generate_changelog():
|
101
|
+
fn = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
|
102
|
+
'CHANGES'))
|
103
|
+
f = file(fn)
|
104
|
+
result = []
|
105
|
+
in_header = False
|
106
|
+
header = True
|
107
|
+
for line in f:
|
108
|
+
if header:
|
109
|
+
if not in_header and line.strip():
|
110
|
+
in_header = True
|
111
|
+
elif in_header and not line.strip():
|
112
|
+
header = False
|
113
|
+
else:
|
114
|
+
result.append(line.rstrip())
|
115
|
+
f.close()
|
116
|
+
return '\n'.join(result).decode('utf-8')
|
117
|
+
|
118
|
+
def generate_authors():
|
119
|
+
fn = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
|
120
|
+
'AUTHORS'))
|
121
|
+
f = file(fn)
|
122
|
+
r = f.read().rstrip().decode('utf-8')
|
123
|
+
f.close()
|
124
|
+
return r
|
125
|
+
|
126
|
+
LEXERDOCS = generate_lexer_docs()
|
127
|
+
FORMATTERDOCS = generate_formatter_docs()
|
128
|
+
FILTERDOCS = generate_filter_docs()
|
129
|
+
CHANGELOG = generate_changelog()
|
130
|
+
AUTHORS = generate_authors()
|
131
|
+
|
132
|
+
|
133
|
+
PYGMENTS_FORMATTER = HtmlFormatter(style='pastie', cssclass='syntax')
|
134
|
+
|
135
|
+
USAGE = '''\
|
136
|
+
Usage: %s <mode> <destination> [<source.txt> ...]
|
137
|
+
|
138
|
+
Generate either python or html files out of the documentation.
|
139
|
+
|
140
|
+
Mode can either be python or html.\
|
141
|
+
''' % sys.argv[0]
|
142
|
+
|
143
|
+
TEMPLATE = '''\
|
144
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
145
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
146
|
+
<html>
|
147
|
+
<head>
|
148
|
+
<title>{{ title }} — Pygments</title>
|
149
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
150
|
+
<style type="text/css">
|
151
|
+
{{ style }}
|
152
|
+
</style>
|
153
|
+
</head>
|
154
|
+
<body>
|
155
|
+
<div id="content">
|
156
|
+
<h1 class="heading">Pygments</h1>
|
157
|
+
<h2 class="subheading">{{ title }}</h2>
|
158
|
+
{% if file_id != "index" %}
|
159
|
+
<a id="backlink" href="index.html">« Back To Index</a>
|
160
|
+
{% endif %}
|
161
|
+
{% if toc %}
|
162
|
+
<div class="toc">
|
163
|
+
<h2>Contents</h2>
|
164
|
+
<ul class="contents">
|
165
|
+
{% for key, value in toc %}
|
166
|
+
<li><a href="{{ key }}">{{ value }}</a></li>
|
167
|
+
{% endfor %}
|
168
|
+
</ul>
|
169
|
+
</div>
|
170
|
+
{% endif %}
|
171
|
+
{{ body }}
|
172
|
+
</div>
|
173
|
+
</body>
|
174
|
+
<!-- generated on: {{ generation_date }}
|
175
|
+
file id: {{ file_id }} -->
|
176
|
+
</html>\
|
177
|
+
'''
|
178
|
+
|
179
|
+
STYLESHEET = '''\
|
180
|
+
body {
|
181
|
+
background-color: #f2f2f2;
|
182
|
+
margin: 0;
|
183
|
+
padding: 0;
|
184
|
+
font-family: 'Georgia', serif;
|
185
|
+
color: #111;
|
186
|
+
}
|
187
|
+
|
188
|
+
#content {
|
189
|
+
background-color: white;
|
190
|
+
padding: 20px;
|
191
|
+
margin: 20px auto 20px auto;
|
192
|
+
max-width: 800px;
|
193
|
+
border: 4px solid #ddd;
|
194
|
+
}
|
195
|
+
|
196
|
+
h1 {
|
197
|
+
font-weight: normal;
|
198
|
+
font-size: 40px;
|
199
|
+
color: #09839A;
|
200
|
+
}
|
201
|
+
|
202
|
+
h2 {
|
203
|
+
font-weight: normal;
|
204
|
+
font-size: 30px;
|
205
|
+
color: #C73F00;
|
206
|
+
}
|
207
|
+
|
208
|
+
h1.heading {
|
209
|
+
margin: 0 0 30px 0;
|
210
|
+
}
|
211
|
+
|
212
|
+
h2.subheading {
|
213
|
+
margin: -30px 0 0 45px;
|
214
|
+
}
|
215
|
+
|
216
|
+
h3 {
|
217
|
+
margin-top: 30px;
|
218
|
+
}
|
219
|
+
|
220
|
+
table.docutils {
|
221
|
+
border-collapse: collapse;
|
222
|
+
border: 2px solid #aaa;
|
223
|
+
margin: 0.5em 1.5em 0.5em 1.5em;
|
224
|
+
}
|
225
|
+
|
226
|
+
table.docutils td {
|
227
|
+
padding: 2px;
|
228
|
+
border: 1px solid #ddd;
|
229
|
+
}
|
230
|
+
|
231
|
+
p, li, dd, dt, blockquote {
|
232
|
+
font-size: 15px;
|
233
|
+
color: #333;
|
234
|
+
}
|
235
|
+
|
236
|
+
p {
|
237
|
+
line-height: 150%;
|
238
|
+
margin-bottom: 0;
|
239
|
+
margin-top: 10px;
|
240
|
+
}
|
241
|
+
|
242
|
+
hr {
|
243
|
+
border-top: 1px solid #ccc;
|
244
|
+
border-bottom: 0;
|
245
|
+
border-right: 0;
|
246
|
+
border-left: 0;
|
247
|
+
margin-bottom: 10px;
|
248
|
+
margin-top: 20px;
|
249
|
+
}
|
250
|
+
|
251
|
+
dl {
|
252
|
+
margin-left: 10px;
|
253
|
+
}
|
254
|
+
|
255
|
+
li, dt {
|
256
|
+
margin-top: 5px;
|
257
|
+
}
|
258
|
+
|
259
|
+
dt {
|
260
|
+
font-weight: bold;
|
261
|
+
}
|
262
|
+
|
263
|
+
th {
|
264
|
+
text-align: left;
|
265
|
+
}
|
266
|
+
|
267
|
+
a {
|
268
|
+
color: #990000;
|
269
|
+
}
|
270
|
+
|
271
|
+
a:hover {
|
272
|
+
color: #c73f00;
|
273
|
+
}
|
274
|
+
|
275
|
+
pre {
|
276
|
+
background-color: #f9f9f9;
|
277
|
+
border-top: 1px solid #ccc;
|
278
|
+
border-bottom: 1px solid #ccc;
|
279
|
+
padding: 5px;
|
280
|
+
font-size: 13px;
|
281
|
+
font-family: Bitstream Vera Sans Mono,monospace;
|
282
|
+
}
|
283
|
+
|
284
|
+
tt {
|
285
|
+
font-size: 13px;
|
286
|
+
font-family: Bitstream Vera Sans Mono,monospace;
|
287
|
+
color: black;
|
288
|
+
padding: 1px 2px 1px 2px;
|
289
|
+
background-color: #f0f0f0;
|
290
|
+
}
|
291
|
+
|
292
|
+
cite {
|
293
|
+
/* abusing <cite>, it's generated by ReST for `x` */
|
294
|
+
font-size: 13px;
|
295
|
+
font-family: Bitstream Vera Sans Mono,monospace;
|
296
|
+
font-weight: bold;
|
297
|
+
font-style: normal;
|
298
|
+
}
|
299
|
+
|
300
|
+
#backlink {
|
301
|
+
float: right;
|
302
|
+
font-size: 11px;
|
303
|
+
color: #888;
|
304
|
+
}
|
305
|
+
|
306
|
+
div.toc {
|
307
|
+
margin: 0 0 10px 0;
|
308
|
+
}
|
309
|
+
|
310
|
+
div.toc h2 {
|
311
|
+
font-size: 20px;
|
312
|
+
}
|
313
|
+
''' #'
|
314
|
+
|
315
|
+
|
316
|
+
def pygments_directive(name, arguments, options, content, lineno,
|
317
|
+
content_offset, block_text, state, state_machine):
|
318
|
+
try:
|
319
|
+
lexer = get_lexer_by_name(arguments[0])
|
320
|
+
except ValueError:
|
321
|
+
# no lexer found
|
322
|
+
lexer = get_lexer_by_name('text')
|
323
|
+
parsed = highlight(u'\n'.join(content), lexer, PYGMENTS_FORMATTER)
|
324
|
+
return [nodes.raw('', parsed, format="html")]
|
325
|
+
pygments_directive.arguments = (1, 0, 1)
|
326
|
+
pygments_directive.content = 1
|
327
|
+
directives.register_directive('sourcecode', pygments_directive)
|
328
|
+
|
329
|
+
|
330
|
+
def create_translator(link_style):
|
331
|
+
class Translator(html4css1.HTMLTranslator):
|
332
|
+
def visit_reference(self, node):
|
333
|
+
refuri = node.get('refuri')
|
334
|
+
if refuri is not None and '/' not in refuri and refuri.endswith('.txt'):
|
335
|
+
node['refuri'] = link_style(refuri[:-4])
|
336
|
+
html4css1.HTMLTranslator.visit_reference(self, node)
|
337
|
+
return Translator
|
338
|
+
|
339
|
+
|
340
|
+
class DocumentationWriter(html4css1.Writer):
|
341
|
+
|
342
|
+
def __init__(self, link_style):
|
343
|
+
html4css1.Writer.__init__(self)
|
344
|
+
self.translator_class = create_translator(link_style)
|
345
|
+
|
346
|
+
def translate(self):
|
347
|
+
html4css1.Writer.translate(self)
|
348
|
+
# generate table of contents
|
349
|
+
contents = self.build_contents(self.document)
|
350
|
+
contents_doc = self.document.copy()
|
351
|
+
contents_doc.children = contents
|
352
|
+
contents_visitor = self.translator_class(contents_doc)
|
353
|
+
contents_doc.walkabout(contents_visitor)
|
354
|
+
self.parts['toc'] = self._generated_toc
|
355
|
+
|
356
|
+
def build_contents(self, node, level=0):
|
357
|
+
sections = []
|
358
|
+
i = len(node) - 1
|
359
|
+
while i >= 0 and isinstance(node[i], nodes.section):
|
360
|
+
sections.append(node[i])
|
361
|
+
i -= 1
|
362
|
+
sections.reverse()
|
363
|
+
toc = []
|
364
|
+
for section in sections:
|
365
|
+
try:
|
366
|
+
reference = nodes.reference('', '', refid=section['ids'][0], *section[0])
|
367
|
+
except IndexError:
|
368
|
+
continue
|
369
|
+
ref_id = reference['refid']
|
370
|
+
text = escape(reference.astext())
|
371
|
+
toc.append((ref_id, text))
|
372
|
+
|
373
|
+
self._generated_toc = [('#%s' % href, caption) for href, caption in toc]
|
374
|
+
# no further processing
|
375
|
+
return []
|
376
|
+
|
377
|
+
|
378
|
+
def generate_documentation(data, link_style):
|
379
|
+
writer = DocumentationWriter(link_style)
|
380
|
+
data = data.replace('[builtin_lexer_docs]', LEXERDOCS).\
|
381
|
+
replace('[builtin_formatter_docs]', FORMATTERDOCS).\
|
382
|
+
replace('[builtin_filter_docs]', FILTERDOCS).\
|
383
|
+
replace('[changelog]', CHANGELOG).\
|
384
|
+
replace('[authors]', AUTHORS)
|
385
|
+
parts = publish_parts(
|
386
|
+
data,
|
387
|
+
writer=writer,
|
388
|
+
settings_overrides={
|
389
|
+
'initial_header_level': 3,
|
390
|
+
'field_name_limit': 50,
|
391
|
+
}
|
392
|
+
)
|
393
|
+
return {
|
394
|
+
'title': parts['title'],
|
395
|
+
'body': parts['body'],
|
396
|
+
'toc': parts['toc']
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
def handle_python(filename, fp, dst):
|
401
|
+
now = datetime.now()
|
402
|
+
title = os.path.basename(filename)[:-4]
|
403
|
+
content = fp.read()
|
404
|
+
def urlize(href):
|
405
|
+
# create links for the pygments webpage
|
406
|
+
if href == 'index.txt':
|
407
|
+
return '/docs/'
|
408
|
+
else:
|
409
|
+
return '/docs/%s/' % href
|
410
|
+
parts = generate_documentation(content, urlize)
|
411
|
+
result = file(os.path.join(dst, title + '.py'), 'w')
|
412
|
+
result.write('# -*- coding: utf-8 -*-\n')
|
413
|
+
result.write('"""\n Pygments Documentation - %s\n' % title)
|
414
|
+
result.write(' %s\n\n' % ('~' * (24 + len(title))))
|
415
|
+
result.write(' Generated on: %s\n"""\n\n' % now)
|
416
|
+
result.write('import datetime\n')
|
417
|
+
result.write('DATE = %r\n' % now)
|
418
|
+
result.write('TITLE = %r\n' % parts['title'])
|
419
|
+
result.write('TOC = %r\n' % parts['toc'])
|
420
|
+
result.write('BODY = %r\n' % parts['body'])
|
421
|
+
result.close()
|
422
|
+
|
423
|
+
|
424
|
+
def handle_html(filename, fp, dst):
|
425
|
+
now = datetime.now()
|
426
|
+
title = os.path.basename(filename)[:-4]
|
427
|
+
content = fp.read().decode('utf-8')
|
428
|
+
c = generate_documentation(content, (lambda x: './%s.html' % x))
|
429
|
+
result = file(os.path.join(dst, title + '.html'), 'w')
|
430
|
+
c['style'] = STYLESHEET + PYGMENTS_FORMATTER.get_style_defs('.syntax')
|
431
|
+
c['generation_date'] = now
|
432
|
+
c['file_id'] = title
|
433
|
+
t = Template(TEMPLATE)
|
434
|
+
result.write(t.render(c).encode('utf-8'))
|
435
|
+
result.close()
|
436
|
+
|
437
|
+
|
438
|
+
def run(handle_file, dst, sources=()):
|
439
|
+
path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
|
440
|
+
if not sources:
|
441
|
+
sources = [os.path.join(path, fn) for fn in os.listdir(path)]
|
442
|
+
if not os.path.isdir(dst):
|
443
|
+
os.makedirs(dst)
|
444
|
+
print 'Making docs for Pygments %s in %s' % (__version__, dst)
|
445
|
+
for fn in sources:
|
446
|
+
if not os.path.isfile(fn):
|
447
|
+
continue
|
448
|
+
print 'Processing %s' % fn
|
449
|
+
f = open(fn)
|
450
|
+
try:
|
451
|
+
handle_file(fn, f, dst)
|
452
|
+
finally:
|
453
|
+
f.close()
|
454
|
+
|
455
|
+
|
456
|
+
def main(mode, dst='build/', *sources):
|
457
|
+
try:
|
458
|
+
handler = {
|
459
|
+
'html': handle_html,
|
460
|
+
'python': handle_python
|
461
|
+
}[mode]
|
462
|
+
except KeyError:
|
463
|
+
print 'Error: unknown mode "%s"' % mode
|
464
|
+
sys.exit(1)
|
465
|
+
run(handler, os.path.realpath(dst), sources)
|
466
|
+
|
467
|
+
|
468
|
+
if __name__ == '__main__':
|
469
|
+
if len(sys.argv) == 1:
|
470
|
+
print USAGE
|
471
|
+
else:
|
472
|
+
main(*sys.argv[1:])
|