I thought finding such was very easy but I couldn't find any pointer
in the Internet. I would like to put my Python code to my Intranet.
Instead of putting a plain text, I would like to put a HTMLized code
(with keyword coloring, simple links to def, class, ...)
I found so many articles, postings regarding to Python's HTML modules.
Also, there must be a tool to create a HTML page summarizing a class
(class name, member function, ...). But not python source code itself.
Yes, I understand putting a whole source code is not so useful for a
big complex program. But my program is not so big such that showing
the entire source code is still very helpful.
Is there any software tool to create a HTML page from Python source code?
Any info would be highly appreciated.
Best regards,
Aki Niimura
> Hello everyone,
>
> I thought finding such was very easy but I couldn't find any pointer
> in the Internet. I would like to put my Python code to my Intranet.
>
> Instead of putting a plain text, I would like to put a HTMLized code
> (with keyword coloring, simple links to def, class, ...)
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
(most popular recipe currently in the Cookbook, apparently!)
or for somewhat-richer functionality:
http://www.norvig.com/python/py2html.html
http://www.danbala.com/python/lpy/lpy.py.html
and no doubt many others.
Alex
There is a pure Python solution here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
There is a (somewhat more robust) C solution here:
http://silvercity.sourceforge.net/
Just ask on this list if you need help figuring out either.
Cheers,
Brian
> Is there any software tool to create a HTML page from Python source code?
VIM! (www.vim.org)
Vim can write any file that it can syntax-colorize (Python is among the
large set of recognised file types ofcourse) as colorized HTML.
Just type in command mode:
ru syntax/2html.vim
and save the generated HTML buffer.
Irmen de Jong
None of the solutions are pure Python: the cookbook recipe uses the
Python tokenizer, which is written in C. Similarly, in SilverCity, only
the tokenizer is written in C.
SilverCity also corrects a few little weaknesses in the Python tokenizer
solution (*). For example, using the Python tokenizer, line
continuations are removed so continued lines will appear on the same
line in your HTML output.
* BIAS: I wrote SilverCity
Cheers,
Brian
> Is there any software tool to create a HTML page from Python source code?
My usual tool for this kind of work is `enscript', probably available on
your Linux distribution, or obtainable from any GNU repository.
> Instead of putting a plain text, I would like to put a HTMLized code
> (with keyword coloring, simple links to def, class, ...)
However, `enscript' only gives you highlighting, you will not get links.
--
François Pinard http://www.iro.umontreal.ca/~pinard
Twisted has a very neat (and small!) module written by Moshe Zadka, called
twisted.python.htmlizer. It basically wraps your source inside lots of
spans tag, e.g. <span class="py-src-identifier">foo</span>. This means you
can do pretty much all the customisation you need in CSS, without touching
the htmlizer source. It works very well for the HOWTO docs on
twistedmatrix.com -- have a read through them for a demonstration of what it
can do.
-Andrew.
SilverCity does allow you to use your own keywords.
> I'm using a similar tool for another language (HDL), v2html.
That looks like a very cool tool! It would be hard to create a similar
one in Python because of the lack of statically available information.
> I was hoping to have a similar one (more than just coloring ...).
> But probably I'm asking too much.
SilverCity generates hyperlinks for PEPs and URLs, but that's pretty
much all the "extra" that you get. Oh, it also allows you to do
multilingual coloring e.g. embedded SGML code can be styled as SGML, not
just given the Python string style.
> I will try SilverCity when I have a time.
Don't bother if the recipe does what you want. I'm just playing salesman
and telling you about the (probably useless) extra features available in
my model :-)
Cheers,
Brian
If you view source files in SourceForge CVS with browser, they come
out with language-specific colorization. IE, *.py have Python
keywords in keyword color. No idea what use. Assume not written in
Python.
TJR
A common techie misconception. If you were *really* playing salesman you
would be emphasising the benefits those features would bring to your
prospect :-)
but-then-i'm-not-terrific-at-sales-either-ly y'rs - steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
Register for PyCon now! http://www.python.org/pycon/reg.html
There will be in about a week ;)
I'm polishing up my first beta of PyXR right now. It does a
reasonable job of creating cross-referenced hyperlinks. There should
be something on comp.lang.python.announce by this weekend.
> aki...@pacbell.net (Aki Niimura) wrote in message news:<b714b8de.03022...@posting.google.com>...
> > Is there any software tool to create a HTML page from Python source code?
> I'm polishing up my first beta of PyXR right now. It does a
> reasonable job of creating cross-referenced hyperlinks. There should
> be something on comp.lang.python.announce by this weekend.
How does it do at colorizing? Or - given that there are lots of tools
to do colorizing (the cookbook solution, VIM, Emacs, enscript, and
others), how about making it ignore existing HTML tags so I can
colorize it and then use PyXR to create the xreferene links?
<mike
--
Mike Meyer <m...@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Hi Aki,
Hope you don't mind if I wade in with my shameless plug;
http://www.thuswise.co.uk/py2html.html
This is no relation to other "py2html"s that may have been
suggested; it's based on Xavier Defrang's string replacement recipe,
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330 .
Easily adaptible to any other language syntax.
Best Regards,
Dave.
[I have heard that] There are plugins for the jEdit text editor that do
this (generate an HTML representation of source code with syntax
coloring).
Erik
--
Erik Price
email: erik...@mac.com
jabber: erik...@jabber.org
Thank you very much for so many replies. It is almost overwhelming.
This also indicates that there is a reasonable needs for such tool.
At this moment, I used the cookbook solution as I can easily fiddle.
After putting such HTML pages into my Intranet, I concluded coloring
was helpful but not enough. I ended up putting links into the HTML pages
manually.
I hope this kind of tool will be a part of the Python distribution.
(I'm not suggesting one tool for everyone. But one tool could cover 90%)
Cheers,
Aki-
> Is there any software tool to create a HTML page from Python
> source code?
There's GNU source-highlight:
<http://www.gnu.org/software/src-highlite/>
Also available as a Debian package:
<http://packages.debian.org/source-highlight>
Cheers,
// Klaus
--
><> vandag, môre, altyd saam
You need to build a syntax-tree to build the xref'd links. I would
prefer a pure python input to do this. In release one you'll be stuck
with my color scheme, but I plan to yank it out into a customizable
class eventually.
>logi...@zworg.com (logistix) writes:
>How does it do at colorizing? Or - given that there are lots of tools
>to do colorizing (the cookbook solution, VIM, Emacs, enscript, and
>others), how about making it ignore existing HTML tags so I can
>colorize it and then use PyXR to create the xreferene links?
Pardon my ignorance, but what is PyXR? I've googled for the term,
without finding anything relevant.
open your python file
and then File > Export > As HTML
You can use this script (will work for many other languages as well):
----------
#!/bin/bash
# Prepare files for code review
# Author: Miki Tebeka <teb...@cs.bgu.ac.il>
if [ $# -lt 1 ]; then
echo "usage: `basename $0` FILE[s]"
exit 1
fi
for file in $*
do
vim -c 'se nu' -c 'so $VIMRUNTIME/syntax/2html.vim' -c w -c 'qa!' $file
done
---------
HTH.
Miki
>
> On Monday, February 24, 2003, at 12:04 AM, Terry Reedy wrote:
>
>>> Is there any software tool to create a HTML page from Python source
>> code?
The SciTE text editor can export to HTML. It does colored syntax
high-lighting for a variety of languages. SciTE is at:
http://www.scintilla.org/SciTE.html
- Dave
>>
>> If you view source files in SourceForge CVS with browser, they come
>> out with language-specific colorization. IE, *.py have Python
>> keywords in keyword color. No idea what use. Assume not written in
>> Python.
>
> [I have heard that] There are plugins for the jEdit text editor that do
> this (generate an HTML representation of source code with syntax
> coloring).
>
>
>
> Erik
>
>
>
>
>
--
Dave Kuhlman
dkuh...@rexx.com
http://www.rexx.com/~dkuhlman