Merge commit 'f1e7656ed364431346bd49fc172f20e971026345' as 'doc/eldomain'

This commit is contained in:
John Miller 2016-09-09 10:07:58 -05:00
commit dddc3241a5
11 changed files with 1295 additions and 0 deletions

1
doc/eldomain/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
example/build

60
doc/eldomain/README.rst Normal file
View file

@ -0,0 +1,60 @@
======================================================
Emacs Lisp domain -- Sphinx extension for Emacs Lisp
======================================================
Example usage (Emacs IPython Notebook documentation):
http://tkf.github.com/emacs-ipython-notebook/
Setup
=====
You need to have something like this in ``conf.py``::
# Dictionary maps package name to package prefix.
elisp_packages = {
'YOUR-PACKAGE': 'YOUR-PACKAGE-PREFIX-',
'ANOTHER-PACKAGE': 'ANOTHER-PACKAGE-PREFIX:',
}
# These are optional:
emacs_executable = 'emacs'
elisp_pre_load = 'conf.el'
You need to load functions and variables you want to load in ``conf.el``::
(add-to-list 'load-path "PATH/TO/YOUR/PACKAGE/")
(require 'YOUR-PACKAGE)
See the setup for Emacs IPython Notebook:
https://github.com/tkf/emacs-ipython-notebook/tree/master/doc/source
Directives and roles
====================
First of all, you need to specify package to use before using any
other directives.::
.. el:package:: PACKAGE-NAME
Then, you can automatically document function/macro/variables.::
.. el:function:: FUNCTION-NAME
.. el:macro:: MACRO-NAME
.. el:variable:: VARIABLE-NAME
.. TODO: document options for these directives.
You can get well-formatted keybind list using::
.. el:keymap:: KEYMAP-NAME
Finally, you can use ``el:symbol`` role to refer symbols.
For exmaple::
:el:symbol:`FUNCTION-NAME`

105
doc/eldomain/eldomain.el Normal file
View file

@ -0,0 +1,105 @@
;;; eldomain.el --- Generate data for eldomain
;; Copyright (C) 2012- Takafumi Arakaki
;; Author: Takafumi Arakaki
;; This file is NOT part of GNU Emacs.
;; eldomain is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; eldomain is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with eldomain. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(eval-when-compile (require 'cl))
(require 'help-fns)
(require 'json)
(defvar eldomain-prefix nil)
(defun eldomain-get-symbols (predicate)
(loop for x being the symbols
with regexp = (format "^%s" eldomain-prefix)
if (and (funcall predicate x)
(string-match regexp (format "%S" x)))
collect x))
(defun eldomain-get-function-data ()
(loop for x in (eldomain-get-symbols #'fboundp)
for name = (format "%S" x)
for arg = (help-function-arglist x)
for doc = (documentation x)
collect `((name . ,name) (arg . ,arg) (doc . ,doc))))
(defun eldomain-get-variable-data ()
(loop for x in (eldomain-get-symbols #'boundp)
for name = (format "%S" x)
for doc = (documentation-property x 'variable-documentation t)
collect `((name . ,name) (doc . ,doc))))
(defun eldomain-get-face-data ()
(loop for x in (eldomain-get-symbols #'facep)
for name = (format "%S" x)
for doc = (documentation-property x 'face-documentation t)
collect `((name . ,name) (doc . ,doc))))
(defun eldomain-keymap-to-data (keymap)
(let* (data
eldomain-keymap-parent
(eldomain-prefix-regexp (format "^%s" eldomain-prefix))
eldomain-describe-keymap ; to shut up compiler...
(eldomain-describe-keymap
(lambda (event value)
(let* ((parent eldomain-keymap-parent)
(eldomain-keymap-parent (append parent (list event))))
(cond
((keymapp value)
(map-keymap eldomain-describe-keymap value))
((and (listp value) (eq (car value) 'menu-item))
nil) ; ignore menu
(value ; do not record when func is not set
(push (list :key (key-description eldomain-keymap-parent)
:func value
:doc (when (string-match eldomain-prefix-regexp
(format "%S" value))
(documentation value)))
data)))))))
(map-keymap eldomain-describe-keymap keymap)
data))
(defun eldomain-get-keymap-data ()
(loop for x in (eldomain-get-symbols
(lambda (v) (and (boundp v) (keymapp (eval v)))))
for name = (format "%S" x)
for doc = (documentation-property x 'variable-documentation t)
for data = (apply #'vector (eldomain-keymap-to-data (eval x)))
collect `((name . ,name) (doc . ,doc) (data . ,data))))
(defun eldomain-get-data ()
`((function . ,(apply #'vector (eldomain-get-function-data)))
(variable . ,(apply #'vector (eldomain-get-variable-data)))
(face . ,(apply #'vector (eldomain-get-face-data)))
(keymap . ,(apply #'vector (eldomain-get-keymap-data)))))
(defun eldomain-main ()
(assert eldomain-prefix nil "`eldomain-prefix' must be set.")
(princ (json-encode (eldomain-get-data)))
(kill-emacs))
(eldomain-main)
;;; eldomain.el ends here

458
doc/eldomain/eldomain.py Normal file
View file

@ -0,0 +1,458 @@
# eldomain is a Emacs Lisp domain for the Sphinx documentation tool.
# Copyright (C) 2012 Takafumi Arakaki
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
The Emacs Lisp domain
~~~~~~~~~~~~~~~~~~~~~
This Sphinx extension provides directives and roles under the domain
``el`` for documenting Emacs Lisp program. It also provides autodoc
functionality -- docstrings in the Emacs Lisp is automatically
inserted in the documentation.
.. note::
The source code is heavily borrowed from the `Common Lisp domain`_.
.. _`Common Lisp domain`:
https://github.com/russell/sphinxcontrib-cldomain
"""
import os
from os import path
import re
import itertools
import subprocess
import json
from docutils import nodes
from docutils.statemachine import string2lines, StringList
from sphinx import addnodes
from sphinx.locale import l_, _
from sphinx.roles import XRefRole
from sphinx.domains import Domain, ObjType
from sphinx.directives import ObjectDescription
from sphinx.util.nodes import make_refnode
from sphinx.util.compat import Directive
from sphinx.util.docfields import Field, GroupedField
DATA = {}
DATA_DOC_STRINGS = {}
DATA_ARGS = {}
def bool_option(arg):
"""Used to convert flag options to auto directives. (Instead of
directives.flag(), which returns None).
"""
return True
def string_list(delimiter):
"""
Return a parser for option_spec to parse strings separated by `delimiter`.
>>> parser = string_list(',')
>>> parser('a, b, c')
['a', 'b', 'c']
"""
return lambda argument: [v.strip() for v in argument.split(delimiter)]
class ELSExp(ObjectDescription):
doc_field_types = [
GroupedField('parameter', label=l_('Parameters'),
names=('param', 'parameter', 'arg', 'argument',
'keyword', 'kwparam')),
Field('returnvalue', label=l_('Returns'), has_arg=False,
names=('returns', 'return')),
]
option_spec = {
'nodoc': bool_option, 'noindex': bool_option,
}
def handle_signature(self, sig, signode):
symbol_name = []
def render_sexp(sexp, signode=None, prepend_node=None):
desc_sexplist = addnodes.desc_parameterlist()
desc_sexplist.child_text_separator = ' '
if prepend_node:
desc_sexplist.append(prepend_node)
if signode:
signode.append(desc_sexplist)
for atom in sexp:
if isinstance(atom, list):
render_sexp(atom, desc_sexplist)
else:
render_atom(atom, desc_sexplist)
return desc_sexplist
def render_atom(token, signode, noemph=True):
"add syntax hi-lighting to interesting atoms"
if token.startswith("&") or token.startswith(":"):
signode.append(addnodes.desc_parameter(token, token))
else:
signode.append(addnodes.desc_parameter(token, token))
package = self.env.temp_data.get('el:package')
objtype = self.get_signature_prefix(sig)
signode.append(addnodes.desc_annotation(objtype, objtype))
lisp_args = DATA_ARGS.get(package, {}).get(sig, [])
if lisp_args:
function_name = addnodes.desc_name(sig, sig + " ")
else:
function_name = addnodes.desc_name(sig, sig)
if lisp_args:
arg_list = render_sexp(lisp_args, prepend_node=function_name)
signode.append(arg_list)
else:
signode.append(function_name)
symbol_name = sig
if not symbol_name:
raise Exception("Unknown symbol type for signature %s" % sig)
return objtype.strip(), symbol_name
def get_index_text(self, name, type):
return _('%s (Lisp %s)') % (name, type)
def get_signature_prefix(self, sig):
return self.objtype + ' '
def add_target_and_index(self, name, sig, signode):
# note target
type, name = name
if name not in self.state.document.ids:
signode['names'].append(name)
signode['ids'].append(name)
signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode)
inv = self.env.domaindata['el']['symbols']
if name in inv:
self.state_machine.reporter.warning(
'duplicate symbol description of %s, ' % name +
'other instance in ' + self.env.doc2path(inv[name][0]),
line=self.lineno)
inv[name] = (self.env.docname, self.objtype)
indextext = self.get_index_text(name, type)
if indextext:
self.indexnode['entries'].append(('single', indextext, name, ''))
def run(self):
result = super(ELSExp, self).run()
if "nodoc" not in self.options:
package = self.env.temp_data.get('el:package')
node = addnodes.desc_content()
string = DATA_DOC_STRINGS.get(package, {}) \
.get(self.names[0][1], "")
lines = string2lines(string)
self.state.nested_parse(StringList(lines), 0, node)
if (result[1][1].children and
isinstance(result[1][1][0], nodes.field_list)):
cresult = result[1][1].deepcopy()
target = result[1][1]
target.clear()
target.append(cresult[0])
target.extend(node)
target.extend(cresult[1:])
else:
cresult = result[1][1].deepcopy()
target = result[1][1]
target.clear()
target.extend(node)
target.extend(cresult)
return result
class ELCurrentPackage(Directive):
"""
This directive is just to tell Sphinx that we're documenting stuff in
namespace foo.
"""
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {}
def run(self):
env = self.state.document.settings.env
env.temp_data['el:package'] = self.arguments[0]
return []
def parse_text_list(argument, delimiter=','):
"""
Converts a space- or comma-separated list of values into a list
"""
if delimiter in argument:
entries = argument.split(delimiter)
else:
entries = argument.split()
return [v.strip() for v in entries]
def compose(f, g):
def h(*args, **kwds):
return f(g(*args, **kwds))
return h
def filter_by_exclude_regexp_list(candidates, regexp_list, getter=lambda x: x):
"""
Exclude elements in `candidates` that matches to one of the regexp.
>>> filter_by_exclude_regexp_list(['a', 'aa', 'bb'], ['a+'])
['bb']
>>> filter_by_exclude_regexp_list(['a', 'ab', 'bb'], ['a+', 'a?b$'])
['bb']
>>> filter_by_exclude_regexp_list(
... [{'key': 'a'}, {'key': 'ab'}, {'key': 'bb'}],
... ['a+', 'a?b$'],
... lambda x: x['key'])
[{'key': 'bb'}]
"""
for compiled in map(re.compile, regexp_list):
test = compose(compiled.match, getter)
candidates = itertools.filterfalse(test, candidates)
return list(candidates)
def simple_sed(scripts, string):
r"""
A simple sed-like function
>>> simple_sed(['s/before/after/g'], 'and then before that ...')
'and then after that ...'
>>> simple_sed([r's/([0-9])/\1\1/g'], 'there are 2 apples')
'there are 22 apples'
"""
for scr in scripts:
scr = scr.lstrip('s')
scr_split = scr[1:].split(scr[0])
(regexp, replace) = scr_split[:2]
string = re.sub(regexp, replace, string)
return string
class ELKeyMap(Directive):
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {
'exclude': parse_text_list,
'replace': string_list('\n'),
}
def run(self):
env = self.state.document.settings.env
package = env.temp_data.get('el:package')
keymap_list = DATA.get(package, {}).get('keymap', [])
keymap_name = self.arguments[0]
for keymap in keymap_list:
if keymap['name'] == keymap_name:
break
else:
return [self.state.reporter.warning(
"Keymap {0} not found".format(keymap_name))]
nodelist = []
mapdoc = keymap['doc']
if mapdoc:
nd = nodes.paragraph()
lines = string2lines(doc_to_rst(mapdoc))
self.state.nested_parse(StringList(lines), 0, nd)
nodelist.append(nd)
exclude = self.options.get('exclude', [])
replace = self.options.get('replace', [])
for keybind in filter_by_exclude_regexp_list(
keymap['data'], exclude, lambda x: x['func']):
desc = addnodes.desc()
desc['domain'] = 'el'
desc['objtype'] = 'keybind'
desc['noindex'] = False
signode = addnodes.desc_signature()
# signode += addnodes.desc_annotation("", 'keybind ')
key = simple_sed(replace, keybind['key'])
signode += addnodes.desc_name("", key)
signode += addnodes.desc_addname("", " " + keybind['func'])
desc += signode
if keybind['doc']:
nd = addnodes.desc_content()
lines = string2lines(doc_to_rst(keybind['doc']))
self.state.nested_parse(StringList(lines), 0, nd)
desc += nodes.definition("", nd)
nodelist.append(desc)
return nodelist
class ELXRefRole(XRefRole):
def process_link(self, env, refnode, has_explicit_title, title, target):
if not has_explicit_title:
target = target.lstrip('~') # only has a meaning for the title
# if the first character is a tilde, don't display the package
if title[0:1] == '~':
title = title[1:]
dot = title.rfind(':')
if dot != -1:
title = title[dot + 1:]
return title, target
class ELDomain(Domain):
"""EL language domain."""
name = 'el'
label = 'Common Lisp'
object_types = {
'package': ObjType(l_('package'), 'package'),
'function': ObjType(l_('function'), 'function'),
'macro': ObjType(l_('macro'), 'macro'),
'variable': ObjType(l_('variable'), 'variable'),
}
directives = {
'package': ELCurrentPackage,
'function': ELSExp,
'macro': ELSExp,
'variable': ELSExp,
'keymap': ELKeyMap,
}
roles = {
'symbol': ELXRefRole(),
}
initial_data = {
'symbols': {},
}
def clear_doc(self, docname):
for fullname, (fn, _) in self.data['symbols'].items():
if fn == docname:
del self.data['symbols'][fullname]
def find_obj(self, env, name):
"""Find a Lisp symbol for "name", perhaps using the given package
Returns a list of (name, object entry) tuples.
"""
symbols = self.data['symbols']
if ":" in name:
if name in symbols:
return [(name, symbols[name])]
else:
def filter_symbols(symbol):
symbol = symbol[0]
if name == symbol:
return True
if ":" in symbol:
symbol = symbol.split(":")[1]
if name == symbol:
return True
return False
return [f for f in filter(filter_symbols, symbols.items())]
def resolve_xref(self, env, fromdocname, builder,
typ, target, node, contnode):
matches = self.find_obj(env, target)
if not matches:
return None
elif len(matches) > 1:
env.warn_node(
'more than one target found for cross-reference '
'%r: %s' % (target, ', '.join(match[0] for match in matches)),
node)
name, obj = matches[0]
return make_refnode(builder, fromdocname, obj[0], name,
contnode, name)
def get_symbols(self):
for refname, (docname, type) in self.data['symbols'].items():
yield (refname, refname, type, docname, refname, 1)
def doc_to_rst(docstring):
docstring = _eldoc_quote_re.sub(r":el:symbol:`\1`", docstring)
return docstring
_eldoc_quote_re = re.compile(r"`(\S+)'")
def index_package(emacs, package, prefix, pre_load, extra_args=[]):
"""Call an external lisp program that will return a dictionary of
doc strings for all public symbols."""
lisp_script = path.join(path.dirname(path.realpath(__file__)),
"eldomain.el")
command = [emacs, "-Q", "-batch", "-l", pre_load,
"--eval", '(setq eldomain-prefix "{0}")'.format(prefix),
"-l", lisp_script] + extra_args
proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
if proc.poll() != 0:
raise RuntimeError(
"Error while executing '{0}'.\n\n"
"STDOUT:\n{1}\n\nSTDERR:\n{2}\n".format(
' '.join(command), stdout, stderr))
DATA[package] = lisp_data = json.loads(stdout.decode())
DATA_DOC_STRINGS[package] = {}
# FIXME: support using same name for function/variable/face
for key in ['face', 'variable', 'function']:
for data in lisp_data[key]:
doc = data['doc']
if doc:
DATA_DOC_STRINGS[package][data['name']] = doc_to_rst(doc)
DATA_ARGS[package] = {}
for data in lisp_data['function']:
DATA_ARGS[package][data['name']] = data['arg']
def load_packages(app):
emacs = app.config.emacs_executable
# `app.confdir` will be ignored if `elisp_pre_load` is an absolute path
pre_load = path.join(app.confdir, app.config.elisp_pre_load)
for (name, prefix) in app.config.elisp_packages.items():
index_package(emacs, name, prefix, pre_load)
def setup(app):
app.add_domain(ELDomain)
app.add_config_value('emacs_executable',
os.getenv("EMACS") or 'emacs',
'env')
app.add_config_value('elisp_pre_load', 'conf.el', 'env')
app.add_config_value('elisp_packages', {}, 'env')
app.connect('builder-inited', load_packages)

View file

@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ELDomainExample.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ELDomainExample.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/ELDomainExample"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ELDomainExample"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

View file

@ -0,0 +1,190 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
set I18NSPHINXOPTS=%SPHINXOPTS% source
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\ELDomainExample.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\ELDomainExample.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end

View file

@ -0,0 +1,2 @@
(add-to-list 'load-path (file-name-directory load-file-name))
(require 'eldomain-example)

View file

@ -0,0 +1,251 @@
# -*- coding: utf-8 -*-
#
# EL Domain Example documentation build configuration file, created by
# sphinx-quickstart on Sun Jun 10 19:32:14 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(os.path.join('..', '..')))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.todo',
'eldomain',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'EL Domain Example'
copyright = u'2012, Takafumi Arakaki'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0'
# The full version, including alpha/beta/rc tags.
release = '0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# 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 patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# 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'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# 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 (relative to this directory) 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_domain_indices = 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, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = 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 = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'ELDomainExampledoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'ELDomainExample.tex', u'EL Domain Example Documentation',
u'Takafumi Arakaki', '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
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'eldomainexample', u'EL Domain Example Documentation',
[u'Takafumi Arakaki'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'ELDomainExample', u'EL Domain Example Documentation',
u'Takafumi Arakaki', 'ELDomainExample', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# -- Options for EL domain -----------------------------------------------------
emacs_executable = 'emacs-snapshot'
elisp_packages = {'eldomain-example': 'ee:'}

View file

@ -0,0 +1,20 @@
(defgroup eldomain-example nil
"Group for `eldomain-example' package."
:group 'application
:prefix "ee:")
(defface ee:face-example
'((t :inherit header-line))
"Face documentation example."
:group 'eldomain-example)
(defvar ee:variable-example nil
"Variable documentation example referring to `ee:function-example'.")
(defmacro ee:macro-example (x y &optional z &rest args)
"Macro documentation example referring to `ee:variable-example'.")
(defun ee:function-example (x y &optional z &rest args)
"Function documentation example referring to `ee:macro-example'.")
(provide 'eldomain-example)

View file

@ -0,0 +1,41 @@
Welcome to EL Domain Example's documentation!
=============================================
These are the example of the output of EL domain.
.. el:package:: eldomain-example
.. el:variable:: ee:face-example
.. el:variable:: ee:variable-example
.. el:macro:: ee:macro-example
.. el:function:: ee:function-example
ReST source code:
.. sourcecode:: rst
.. el:package:: eldomain-example
.. el:variable:: ee:face-example
.. el:variable:: ee:variable-example
.. el:macro:: ee:macro-example
.. el:function:: ee:function-example
Emacs lisp source code:
.. literalinclude:: eldomain-example.el
:language: cl
Other examples
==============
.. toctree::
no-package
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View file

@ -0,0 +1,14 @@
Example usage without specifying package
========================================
.. el:variable:: unknown/variable-example
Documenting variable without specifying package...
.. el:macro:: unknown/macro-example
Documenting face without specifying package...
.. el:function:: unknown/function-example
Documenting function without specifying package...