::Tryptech
Python
PySourceColor is currently at version 2.0 This module is intended to produce colorized HTML, CSS/HTML, and XHTML from Python source code. The HTML output is full of font tags and other crufty HTML bits, but works most anywhere. Unfortunately conversion to CSS will reduce the number of browsers that can show it correctly. wxHTMLWindow is one I can think of. PySourceColor includes CSS, HTML, and XHTML. I have tried to keep it flexible, yet simple enough to understand.( probably not so simple anymore ;) At this point PySourceColor is finished except for final pruning and bug fixing. CSS and XHTML markup produced by PySourceColor are w3c valid.
PySourceColor
Many features added and a few bugs squashed.
If you have an earlier version please upgrade. This module works from the commandline with options, and stdIO.
It is a standalone Python code colorizer that can also be imported and used in other programs.
I have personally tested this on Windows XP, Windows 2000, Windows 98, Linux.
Please email me if you have
bugs or
comments.
There is much more possible , I will leave it for you to discover!
Documentaion is in the code.
PyDocs: Example output:
- null
- null_css
- mono
- mono_css
- lite
- lite_css
- lite_xhtml
- dark
- dark_css
- dark2
- dark2_css
- dark2_xhtml
- idle
- idle_css
- viewcvs
- viewcvs_css
- pythonwin
- pythonwin_css
- decorator & string test
Custom scheme test:
- customscheme_test_html # ugly test!
- customscheme_test_css # ugly test!
-Place in Python/Lib folder
Test:
-Run python Lib/PySourceColor.py -t from a commandline to test.
OR
-Run python Lib/PySourceColor.py -t -s from a commandline to test and show.
Pydoc
Well, if you write a source colorizer the next step is to integrate it into pydoc ;) This version of pydoc serves documentation and colorized source.( top right links ) Mozilla is built in such a way that it will ignore local links (no response when clicked). Obviously that makes pydoc's links on the top right fail with Mozilla/Firefox. The pydoc serves its pages instead of using local linking. Works around the problem in a very acceptable way, just serve the page directly! Jeff Epler posted a patch on Usenet and I used it as a starting point. I have extended it to include a few things (colorized source), added some changes for docfile writing (link paths were absolute), and added a few bugs too :( Warning this works well in server mode -g , but writing out docs -w is still flaky. Consider this a proof of concept, there is more to be done.
-Rename your pydoc.py to pydoc.py.bak
-Put PySourceColor.py and a version of pydoc.py in your PythonXX/Lib folder.
-Delete the pydoc.pyc file from the PythonXX/Lib dir if present.
Test:
-Go to a commandline and type: 'python PythonXX/Lib/pydoc.py -g' for the doc server
OR
-You can also write docs to file try: 'python PythonXX/Lib/pydoc.py -w YourModule'