Skip to content

Commit 9767ffe

Browse files
stsewdbfredl
authored andcommitted
Project documentation using Sphinx (neovim#302)
1 parent f9e56f8 commit 9767ffe

16 files changed

+557
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ dist/
88
.cache
99
.eggs
1010
.tox
11+
12+
# Sphinx documentation
13+
docs/_build/

.readthedocs.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build:
2+
image: latest
3+
4+
python:
5+
version: 3.6
6+
setup_py_install: true

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = Neovim
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/api/buffer.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Buffer Class
2+
============
3+
4+
.. autoclass:: neovim.api.Buffer
5+
:members:

docs/api/nvim.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Nvim Class
2+
==========
3+
4+
An instance of this class is used by remote plugins.
5+
6+
.. autoclass:: neovim.api.Nvim
7+
:members:

docs/api/tabpage.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Tabpage Class
2+
=============
3+
4+
.. autoclass:: neovim.api.Tabpage
5+
:members:

docs/api/window.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Window Class
2+
============
3+
4+
.. autoclass:: neovim.api.Window
5+
:members:

docs/conf.py

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Neovim documentation build configuration file, created by
5+
# sphinx-quickstart on Sat Feb 3 12:15:22 2018.
6+
#
7+
# This file is execfile()d with the current directory set to its
8+
# containing dir.
9+
#
10+
# Note that not all possible configuration values are present in this
11+
# autogenerated file.
12+
#
13+
# All configuration values have a default; values that are commented out
14+
# serve to show the default.
15+
16+
# If extensions (or modules to document with autodoc) are in another directory,
17+
# add these directories to sys.path here. If the directory is relative to the
18+
# documentation root, use os.path.abspath to make it absolute, like shown here.
19+
#
20+
# import os
21+
# import sys
22+
# sys.path.insert(0, os.path.abspath('./'))
23+
import datetime
24+
25+
26+
# -- General configuration ------------------------------------------------
27+
28+
# If your documentation needs a minimal Sphinx version, state it here.
29+
#
30+
# needs_sphinx = '1.0'
31+
32+
# Add any Sphinx extension module names here, as strings. They can be
33+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34+
# ones.
35+
extensions = ['sphinx.ext.autodoc',
36+
'sphinx.ext.viewcode']
37+
38+
# Add any paths that contain templates here, relative to this directory.
39+
templates_path = ['_templates']
40+
41+
# The suffix(es) of source filenames.
42+
# You can specify multiple suffix as a list of string:
43+
#
44+
# source_suffix = ['.rst', '.md']
45+
source_suffix = '.rst'
46+
47+
# The master toctree document.
48+
master_doc = 'index'
49+
50+
# General information about the project.
51+
project = 'Neovim Python Client'
52+
copyright = '2014 - {year}, Neovim'.format(
53+
year=datetime.datetime.now().year
54+
)
55+
author = 'Neovim'
56+
57+
# The version info for the project you're documenting, acts as replacement for
58+
# |version| and |release|, also used in various other places throughout the
59+
# built documents.
60+
#
61+
# The short X.Y version.
62+
version = ''
63+
# The full version, including alpha/beta/rc tags.
64+
release = ''
65+
66+
# The language for content autogenerated by Sphinx. Refer to documentation
67+
# for a list of supported languages.
68+
#
69+
# This is also used if you do content translation via gettext catalogs.
70+
# Usually you set "language" from the command line for these cases.
71+
language = None
72+
73+
# List of patterns, relative to source directory, that match files and
74+
# directories to ignore when looking for source files.
75+
# This patterns also effect to html_static_path and html_extra_path
76+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
77+
78+
# The name of the Pygments (syntax highlighting) style to use.
79+
pygments_style = 'sphinx'
80+
81+
# If true, `todo` and `todoList` produce output, else they produce nothing.
82+
todo_include_todos = False
83+
84+
85+
# -- Options for HTML output ----------------------------------------------
86+
87+
# The theme to use for HTML and HTML Help pages. See the documentation for
88+
# a list of builtin themes.
89+
#
90+
html_theme = 'sphinx_rtd_theme'
91+
92+
# Theme options are theme-specific and customize the look and feel of a theme
93+
# further. For a list of options available for each theme, see the
94+
# documentation.
95+
#
96+
# html_theme_options = {}
97+
98+
# Add any paths that contain custom static files (such as style sheets) here,
99+
# relative to this directory. They are copied after the builtin static files,
100+
# so a file named "default.css" will overwrite the builtin "default.css".
101+
html_static_path = ['_static']
102+
103+
104+
# -- Options for HTMLHelp output ------------------------------------------
105+
106+
# Output file base name for HTML help builder.
107+
htmlhelp_basename = 'Neovimdoc'
108+
109+
110+
# -- Options for LaTeX output ---------------------------------------------
111+
112+
latex_elements = {
113+
# The paper size ('letterpaper' or 'a4paper').
114+
#
115+
# 'papersize': 'letterpaper',
116+
117+
# The font size ('10pt', '11pt' or '12pt').
118+
#
119+
# 'pointsize': '10pt',
120+
121+
# Additional stuff for the LaTeX preamble.
122+
#
123+
# 'preamble': '',
124+
125+
# Latex figure (float) alignment
126+
#
127+
# 'figure_align': 'htbp',
128+
}
129+
130+
# Grouping the document tree into LaTeX files. List of tuples
131+
# (source start file, target name, title,
132+
# author, documentclass [howto, manual, or own class]).
133+
latex_documents = [
134+
(master_doc, 'Neovim.tex', 'Neovim Documentation',
135+
'Neovim', 'manual'),
136+
]
137+
138+
139+
# -- Options for manual page output ---------------------------------------
140+
141+
# One entry per manual page. List of tuples
142+
# (source start file, name, description, authors, manual section).
143+
man_pages = [
144+
(master_doc, 'neovim', 'Neovim Documentation',
145+
[author], 1)
146+
]
147+
148+
149+
# -- Options for Texinfo output -------------------------------------------
150+
151+
# Grouping the document tree into Texinfo files. List of tuples
152+
# (source start file, target name, title, author,
153+
# dir menu entry, description, category)
154+
texinfo_documents = [
155+
(master_doc, 'Neovim', 'Neovim Documentation',
156+
author, 'Neovim', 'One line description of project.',
157+
'Miscellaneous'),
158+
]
159+
160+
161+

docs/development.rst

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Development
2+
===========
3+
4+
If you change the code, you need to run::
5+
6+
pip2 install .
7+
pip3 install .
8+
9+
for the changes to have effect.
10+
Alternatively you could execute Neovim with the ``$PYTHONPATH`` environment variable::
11+
12+
PYTHONPATH=/path/to/python-client nvim
13+
14+
But note this is not completely reliable,
15+
as installed packages can appear before ``$PYTHONPATH`` in the python search path.
16+
17+
You need to rerun this command if you have changed the code,
18+
in order for Neovim to use it for the plugin host.
19+
20+
To run the tests execute::
21+
22+
nosetests
23+
24+
This will run the tests in an embedded instance of Neovim.
25+
If you want to test a different version than ``nvim`` in ``$PATH`` use::
26+
27+
NVIM_CHILD_ARGV='["/path/to/nvim", "-u", "NONE", "--embed"]' nosetests
28+
29+
Alternatively, if you want to see the state of nvim, you could use::
30+
31+
export NVIM_LISTEN_ADDRESS=/tmp/nvimtest
32+
xterm -e "nvim -u NONE"&
33+
nosetests
34+
35+
But note you need to restart Neovim every time you run the tests!
36+
Substitute your favorite terminal emulator for ``xterm``.
37+
38+
Troubleshooting
39+
---------------
40+
41+
You can run the plugin host in Neovim with logging enabled to debug errors::
42+
43+
NVIM_PYTHON_LOG_FILE=logfile NVIM_PYTHON_LOG_LEVEL=DEBUG nvim
44+
45+
As more than one Python host process might be started,
46+
the log filenames take the pattern ``logfile_pyX_KIND``
47+
where ``X`` is the major python version (2 or 3)
48+
and ``KIND`` is either "rplugin" or "script" (for the ``:python[3]`` script interface).
49+
50+
If the host cannot start at all,
51+
the error could be found in ``~/.nvimlog`` if ``nvim`` was compiled with logging.
52+
53+
Usage through the Python REPL
54+
-----------------------------
55+
56+
A number of different transports are supported,
57+
but the simplest way to get started is with the python REPL.
58+
First, start Neovim with a known address (or use the ``$NVIM_LISTEN_ADDRESS`` of a running instance)::
59+
60+
NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
61+
62+
In another terminal,
63+
connect a python REPL to Neovim (note that the API is similar to the one exposed by the `python-vim bridge`_):
64+
65+
.. code-block:: python
66+
67+
>>> from neovim import attach
68+
# Create a python API session attached to unix domain socket created above:
69+
>>> nvim = attach('socket', path='/tmp/nvim')
70+
# Now do some work.
71+
>>> buffer = nvim.current.buffer # Get the current buffer
72+
>>> buffer[0] = 'replace first line'
73+
>>> buffer[:] = ['replace whole buffer']
74+
>>> nvim.command('vsplit')
75+
>>> nvim.windows[1].width = 10
76+
>>> nvim.vars['global_var'] = [1, 2, 3]
77+
>>> nvim.eval('g:global_var')
78+
[1, 2, 3]
79+
80+
.. _`python-vim bridge`: http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python-vim
81+
82+
You can embed Neovim into your python application instead of binding to a running neovim instance:
83+
84+
.. code-block:: python
85+
86+
>>> from neovim import attach
87+
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed"])
88+
89+
The tests can be consulted for more examples.

docs/index.rst

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Neovim Python Client
2+
====================
3+
4+
Implements support for Python plugins in `Neovim`_.
5+
Also works as a library for connecting to and scripting Neovim processes through its msgpack-rpc API.
6+
7+
.. _`Neovim`: http://neovim.io/
8+
9+
.. toctree::
10+
:caption: Getting started
11+
:maxdepth: 2
12+
13+
installation
14+
15+
.. toctree::
16+
:caption: Usage
17+
:maxdepth: 2
18+
19+
usage/python-plugin-api
20+
usage/remote-plugins
21+
22+
.. toctree::
23+
:caption: API documentation
24+
:maxdepth: 2
25+
26+
plugin-decorators
27+
api/nvim
28+
api/buffer
29+
api/window
30+
api/tabpage
31+
32+
.. toctree::
33+
:caption: Development
34+
:maxdepth: 2
35+
36+
development

docs/installation.rst

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Installation
2+
============
3+
4+
The Neovim Python client supports Python 2.7, and 3.4 or later.
5+
6+
Using pip
7+
---------
8+
9+
You can install the package without being root by adding the ``--user`` flag::
10+
11+
pip2 install neovim
12+
pip3 install neovim
13+
14+
.. note::
15+
16+
If you only use one of python2 or python3,
17+
it is enough to install that version.
18+
19+
If you follow Neovim master,
20+
make sure to upgrade the ``python-client`` when you upgrade Neovim::
21+
22+
pip2 install --upgrade neovim
23+
pip3 install --upgrade neovim
24+
25+
Install from source
26+
-------------------
27+
28+
Clone the repository somewhere on your disk and enter to the repository::
29+
30+
git clone https://github.com/neovim/python-client.git
31+
cd python-client
32+
33+
Now you can install it on your system::
34+
35+
pip2 install .
36+
pip3 install .

0 commit comments

Comments
 (0)