moved manual from latex to sphinx

This commit is contained in:
Jorgen Stenarson
2008-06-23 19:19:19 +02:00
7 changed files with 459 additions and 245 deletions
+1
View File
@@ -0,0 +1 @@
build
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env python
"""Script to build documentation using Sphinx.
"""
import fileinput,os,sys
def oscmd(c):
os.system(c)
# html manual.
oscmd('sphinx-build -d build/doctrees source build/html')
if sys.platform != 'win32':
# LaTeX format.
oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
# Produce pdf.
topdir = os.getcwd()
os.chdir('build/latex')
# Change chapter style to section style: allows chapters to start on
# the current page. Works much better for the short chapters we have.
# This must go in the class file rather than the preamble, so we modify
# manual.cls at runtime.
chapter_cmds=r'''
% Local changes.
\renewcommand\chapter{
\thispagestyle{plain}
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter
}
\def\@makechapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries \thechapter \quad #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
\def\@makeschapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
'''
unmodified=True
for line in fileinput.FileInput('manual.cls',inplace=1):
if 'Support for module synopsis' in line and unmodified:
line=chapter_cmds+line
elif 'makechapterhead' in line:
# Already have altered manual.cls: don't need to again.
unmodified=False
print line,
# Copying the makefile produced by sphinx...
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('makeindex -s python.ist pyreadline.idx')
oscmd('makeindex -s python.ist modpyreadline.idx')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
# Create a manual/ directory with final html/pdf output
# os.chdir(topdir)
# oscmd('rm -rf manual')
# oscmd('mkdir manual')
# oscmd('cp -r build/html/*.html build/html/_static manual/')
# oscmd('cp build/latex/ipython.pdf manual/')
-200
View File
@@ -1,200 +0,0 @@
\documentclass[11pt,twoside,english]{article}
\usepackage{palatino}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}
\usepackage{color}
\IfFileExists{url.sty}{\usepackage{url}}
{\newcommand{\url}{\texttt}}
\usepackage{color}
% A few colors to replace the defaults for certain link types
\definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
\definecolor{darkorange}{rgb}{.71,0.21,0.01}
\definecolor{darkred}{rgb}{.52,0.08,0.01}
\definecolor{darkgreen}{rgb}{.12,.54,.11}
% Use and configure listings package for nicely formatted code
\usepackage{listings}
\lstset{
language=Python,
basicstyle=\small\ttfamily,
commentstyle=\ttfamily\color{blue},
stringstyle=\ttfamily\color{darkorange},
showstringspaces=false,
breaklines=true,
postbreak = \space\dots
}
\usepackage[%pdftex, % needed for pdflatex
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=blue,
linkcolor=darkred,
citecolor=darkgreen,
]{hyperref}
\usepackage{html}
% This helps prevent overly long lines that stretch beyond the margins
\sloppy
% Define a \codelist command which either uses listings for latex, or
% plain verbatim for html (since latex2html doesn't understand the
% listings package).
\usepackage{verbatim}
\newcommand{\codelist}[1] {
\latex{\lstinputlisting{#1}}
\html{\verbatiminput{#1}}
}
\usepackage{babel}
\begin{document}
\title{pyreadline\\
{\Large a python implementation of GNU readline}{\large }\\
{\large User Manual, v. --version--}}
\author{Jörgen Stenarson}
\maketitle
\latex{\tableofcontents{}}
\html{\bodytext{bgcolor=#ffffff}}
\newpage
\section{Overview}
The pyreadline package is a python implementation of GNU readline. At the moment it is only available for the windows platform. The package is based on the readline package by Gary Bishop. The goal is to provide the functionality of the readline package. New features:
\begin{itemize}
\item International characters
\item Cut and paste from clipboard
\begin{description}
\item[paste] Will paste first line from clipboard (multiple lines doesn't paste well).
\item[ipython\_paste] Smart paste paths, smart paste tab delimited data as list or array.
\item[multiline\_paste] Will assume text on clipobard is python code, removes all empty lines.
\end{description}
\item Bell is disabled by default
\end{itemize}
\subsection{dependencies}
\begin{itemize}
\item ctypes
\item win32all
\end{itemize}
\subsection{Conflicts}
Unfortunately the module rlcompleter, the module that provides tab completion, imports readline which means there must be an alias from readline to pyreadline for things to work properly. This means pyreadline install a file under the name readline.py in site-packages containing:
\lstinputlisting{../readline.py}
\section{Installation}
There are a few things that are not autmatically installed. For instance the configuration file and the startup code that makes sure pyreadline is activated when running python in interactive mode.
However when using ipython pyreadline is imported by default by ipython.
\subsection{Development version}
Use {\ttfamily easy\_install pyreadline==dev} to get development version. Copy pyreadlineconfig.ini from pyreadline/configuration to your HOME directory (usually c:/documents and settings/YOURNAME)
\subsection{Current release version}
\emph{Currently no release version available.}
Use {\ttfamily easy\_install pyreadline} to get development version.
\section{Usage}
The purpose of readline is to improve the interactive experience with the python interpreter by improving the line editing facilities. The most important being tab completion and copy and paste.
\subsection{Configuration file}
The configuration file is read from the users home directory and is named pyreadlineconfig.ini. The files syntax is not the same as for GNU readline but a python syntax is used instead. The available commands are:
\begin{description}
\item[bind\_exit\_key] is used to bind the keys that are used to exit the interpreter. (Ctrl-d, ctrl-z)
\item[bind\_key] is used to bind keys to editor functions
\item[un\_bind\_key] is used to unbind keys can be useful to unbind default bindings the user does not like
\item[bell\_style] is used to set bell style. (none|visible|audible)
\item[show\_all\_if\_ambiguous] is used to enable the showing of a list of all alternative for tab completion (on|off)
\item[mark\_directories] show directories (on|off)
\item[completer\_delims] Which delimeters should be used to separate words for tab completion
\item[debug\_output] Turn on debug output (on|off). Not implemented yet.
\end{description}
Here is the example config file shipped with pyreadline:
\lstinputlisting{../pyreadline/configuration/pyreadlineconfig.ini}
\subsection{pyreadline with python interpreter}
In your startup file (pointed to by environment variable PYTHONSTARTUP) add:
\lstinputlisting{../pyreadline/configuration/startup.py}
This file is included in the doc directory of the distribution.
\subsection{pyreadline with IronPython}
Pyreadline can be used together with IronPython. Unfortunately the binary installs of IronPython can not run pyreadline directly. You need to patch the source code to make PythonCommandLine a public class that we can override.
\begin{itemize}
\item In PythonCommandLine.cs you need to change class PythonCommandLine to public class PythonCommandLine and recompile.
\item Copy rlcompleter.py from a standard python install to your ironpython path (this file is not included with fepy).
\end{itemize}
\subsection{pyreadline with IPython}
In IPython pyreadline is automatically used if available.
\subsection{Clipboard}
Pyreadline can do copy/paste using the clipboard. Selections can be done using shift and arrowkeys as in most windows programs.
There are three different paste functions that can be bound.
\begin{itemize}
\item \emph{paste} Paste windows clipboard.
Assume single line strip other lines and end of line markers and trailing spaces
\item \emph{paste_mulitline_code} Paste windows clipboard as multiline code.
Removes any empty lines in the code
\item \emph{ipython_paste} Paste windows clipboard. If enable_ipython_paste_list_of_lists is
True then try to convert tabseparated data to repr of list of lists or
repr of array. If enable_ipython_paste_for_paths==True then change \\\\ to / and spaces to \\space.
\end{itemize}
\subsection{International characters}
The pyreadline package now supports international characters. However using international characters in the interactive prompt can be annoying on windows since the default codepage for the terminal is an ascii codepage (850 on swedish systems) but the filesystem often uses some other codepage (1252 on swedish systems). This means the filenames containing internationl characters entered on interactive prompt will not work. The workaround here is to change the codepage of your terminal to a more suitable one using the {\ttfamily chcp} command. For swedish systems {\ttfamily chcp 1252} does the trick but you also have to change the terminal font to ``lucida console'' using the properties dialog for the console.
\section{Known issues}
\begin{itemize}
\item If you do not want pyreadline at the standard windows prompt. Delete readline.py
from the install directory. This will not interfere with ipython usage, but you will
not be able to use the rlcompleter module which requires the readline.py module.
\end{itemize}
\section{Future work}
\subsection{Near term}
\begin{itemize}
\item Manual
\end{itemize}
\subsection{Middle term}
\begin{itemize}
\item Add missing functionality
\end{itemize}
\subsection{Long term}
\begin{itemize}
\item Add more platforms
\item Improve vi mode
\end{itemize}
\newpage
\appendix
\section{Bindable commands}
This appendix will contain descriptions of all bindable commands. For now you have to look in the sourcecode. Check the readline class of the file rlmain.py
\end{document}
+178
View File
@@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-
#
# pyreadline documentation build configuration file, created by
# sphinx-quickstart on Sat Jun 21 17:27:19 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default value; values that are commented out
# serve to show the default value.
import sys, os
# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#sys.path.append(os.path.abspath('some/directory'))
# General configuration
# ---------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General substitutions.
project = 'pyreadline'
copyright = '2008, J. Stenarson'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
version = '1.6'
# The full version, including alpha/beta/rc tags.
release = '1.6'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directories, that shouldn't be searched
# for source files.
#exclude_dirs = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# Options for HTML output
# -----------------------
# The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path.
html_style = 'default.css'
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (within the static path) to place at the top of
# the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['.static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, the reST sources are included in the HTML build as _sources/<name>.
#html_copy_source = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'pyreadlinedoc'
# Options for LaTeX output
# ------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
('index', 'pyreadline.tex', 'pyreadline Documentation', 'J. Stenarson', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
+21
View File
@@ -0,0 +1,21 @@
.. pyreadline documentation master file, created by sphinx-quickstart on Sat Jun 21 17:27:19 2008.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pyreadline's documentation!
======================================
Contents:
.. toctree::
:maxdepth: 2
manual_base
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
+185
View File
@@ -0,0 +1,185 @@
pyreadline
==========
a python implementation of GNU readline
---------------------------------------
User Manual, v. --version--
Jörgen Stenarson
Overview
========
The pyreadline package is a python implementation of GNU readline. At the moment it is only available for the windows platform. The package is based on the readline package by Gary Bishop. The goal is to provide the functionality of the readline package. New features:
* International characters
* Cut and paste from clipboard
paste
Will paste first line from clipboard (multiple lines doesn't paste well).
ipython_paste
Smart paste paths, smart paste tab delimited data as list or array.
multiline_paste
Will assume text on clipobard is python code, removes all empty lines.
* Bell is disabled by default
dependencies
------------
* ctypes
* win32all
Conflicts
---------
Unfortunately the module rlcompleter, the module that provides tab completion, imports readline which means there must be an alias from readline to pyreadline for things to work properly. This means pyreadline install a file under the name readline.py in site-packages containing:
.. literalinclude:: ../../readline.py
Installation
============
There are a few things that are not autmatically installed. For instance the configuration file and the startup code that makes sure pyreadline is activated when running python in interactive mode.
However when using ipython pyreadline is imported by default by ipython.
Development version
-------------------
Use :command:`easy_install pyreadline==dev` to get development version. Copy pyreadlineconfig.ini from pyreadline/configuration to your HOME directory (usually c:/documents and settings/YOURNAME)
Current release version
-----------------------
Use :command:`easy\_install pyreadline` to get development version.
Usage
=====
The purpose of readline is to improve the interactive experience with the python interpreter by improving the line editing facilities. The most important being tab completion and copy and paste.
Configuration file
------------------
The configuration file is read from the users home directory and is named pyreadlineconfig.ini. The files syntax is not the same as for GNU readline but a python syntax is used instead. The available commands are:
bind_exit_key
is used to bind the keys that are used to exit the interpreter. (Ctrl-d, ctrl-z)
bind_key
is used to bind keys to editor functions
un_bind_key
is used to unbind keys can be useful to unbind default bindings the user does not like
bell_style
is used to set bell style. (none|visible|audible)
show_all_if_ambiguous
is used to enable the showing of a list of all alternative for tab completion (on|off)
mark_directories
show directories (on|off)
completer_delims
Which delimeters should be used to separate words for tab completion
debug_output
Turn on debug output (on|off). Not implemented yet.
Here is the example config file shipped with pyreadline:
.. literalinclude:: ../../pyreadline/configuration/pyreadlineconfig.ini
pyreadline with python interpreter
----------------------------------
In your startup file (pointed to by environment variable PYTHONSTARTUP) add:
.. literalinclude:: ../../pyreadline/configuration/startup.py
This file is included in the doc directory of the distribution.
pyreadline with IronPython
--------------------------
*THIS HAS NOT BEEN TESTED FOR A WHILE*
Pyreadline can be used together with IronPython. Unfortunately the binary installs of IronPython can not run pyreadline directly. You need to patch the source code to make PythonCommandLine a public class that we can override.
* In PythonCommandLine.cs you need to change class PythonCommandLine to public class PythonCommandLine and recompile.
* Copy rlcompleter.py from a standard python install to your ironpython path (this file is not included with fepy).
pyreadline with IPython
-----------------------
In IPython pyreadline is automatically used if available.
Clipboard
---------
Pyreadline can do copy/paste using the clipboard. Selections can be done using shift and arrowkeys as in most windows programs.
There are three different paste functions that can be bound.
paste
Paste windows clipboard. Assume single line strip other lines and end of line markers and trailing spaces
paste_mulitline_code
Paste windows clipboard as multiline code. Removes any empty lines in the code
ipython_paste
Paste windows clipboard. If enable_ipython_paste_list_of_lists is True then try to convert tabseparated data to repr of list of lists or repr of array. If enable_ipython_paste_for_paths==True then change \\\\ to / and spaces to \\space.
International characters
------------------------
The pyreadline package now supports international characters. However using international characters in the interactive prompt can be annoying on windows since the default codepage for the terminal is an ascii codepage (850 on swedish systems) but the filesystem often uses some other codepage (1252 on swedish systems). This means the filenames containing internationl characters entered on interactive prompt will not work. The workaround here is to change the codepage of your terminal to a more suitable one using the :command:`chcp` command. For swedish systems :command:`chcp 1252` does the trick but you also have to change the terminal font to `lucida console` using the properties dialog for the console.
Known issues
============
* If you do not want pyreadline at the standard windows prompt. Delete readline.py
from the install directory. This will not interfere with ipython usage, but you will
not be able to use the rlcompleter module which requires the readline.py module.
Future work
===========
Near term
---------
* Manual
Middle term
-----------
* Add missing functionality
Long term
---------
* Add more platforms
* Improve vi mode
Bindable commands
=================
This appendix will contain descriptions of all bindable commands. For now you have to look in the sourcecode. Check the readline class of the file rlmain.py
-45
View File
@@ -1,45 +0,0 @@
# Must be launched with the build version of pyreadline on path
#
import re,os
import pyreadline.release as release
def run_shell_command(command,path="",stdin=""):
"""command= commandline, don't forget to qoute paths with spaces
path=path to change to before issuing command
stdin=string string to pass in as standard input
"""
oldpath=os.getcwd()
if path:
os.chdir(path)
(sin,sout,serr)=os.popen3(command)
if stdin:
sin.write(stdin)
sin.close()
txt=sout.read()
errtxt=serr.read()
sout.close()
serr.close()
os.chdir(oldpath)
return txt,errtxt
def build_pdf_doc():
print "latex pass 1"
t,err=run_shell_command("pdflatex -interaction=batchmode manual.tex")
print "latex pass 2"
t,err=run_shell_command("pdflatex -interaction=batchmode manual.tex")
print "removing tempfiles files"
for ext in ["aux","log","out","toc"]:
os.remove("manual.%s"%ext)
fil=open("manual_base.tex")
txt=fil.read()
fil.close()
manualtext=re.sub("--version--",release.version,txt)
fil=open("manual.tex","w")
fil.write(manualtext)
fil.close()
print "Manual (manual.tex) succesfully updated, exiting..."
print "Run pdflatex manual.tex manually to see errors"
build_pdf_doc()