From 29d91a79e623e4cff17546b30a3196deaf51dbd0 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 1 Oct 2020 22:38:56 +0200 Subject: Skeleton of sphinx documentation --- docs/Makefile | 20 +++++++++++++++++ docs/make.bat | 35 ++++++++++++++++++++++++++++++ docs/source/conf.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 20 +++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..df9c092 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,59 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# 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. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'lesana' +copyright = "2020, Elena Grandi" +author = "Elena ``of Valhalla''" + +# The short version +version = '0.6' +# The full version, including alpha/beta/rc tags +release = '0.6.0' + + +# -- 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 = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.viewcode', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- 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 = 'alabaster' + +# 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'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..582b0f3 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. lesana documentation master file, created by + sphinx-quickstart on Thu Oct 1 22:28:26 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to lesana's documentation! +================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` -- cgit v1.2.3 From d120ee47de7d3c02a8420e3a615c6269f88def9c Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 1 Oct 2020 22:40:06 +0200 Subject: Autogenerated autodoc files sphinx-apidoc -f -e -M -o docs/source/reference/ lesana/ --- docs/source/index.rst | 2 ++ docs/source/reference/lesana.collection.rst | 7 +++++++ docs/source/reference/lesana.command.rst | 7 +++++++ docs/source/reference/lesana.data.rst | 7 +++++++ docs/source/reference/lesana.rst | 24 ++++++++++++++++++++++++ docs/source/reference/modules.rst | 7 +++++++ 6 files changed, 54 insertions(+) create mode 100644 docs/source/reference/lesana.collection.rst create mode 100644 docs/source/reference/lesana.command.rst create mode 100644 docs/source/reference/lesana.data.rst create mode 100644 docs/source/reference/lesana.rst create mode 100644 docs/source/reference/modules.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 582b0f3..fbc0ce9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,6 +10,8 @@ Welcome to lesana's documentation! :maxdepth: 2 :caption: Contents: + reference/modules + Indices and tables diff --git a/docs/source/reference/lesana.collection.rst b/docs/source/reference/lesana.collection.rst new file mode 100644 index 0000000..e00613c --- /dev/null +++ b/docs/source/reference/lesana.collection.rst @@ -0,0 +1,7 @@ +lesana.collection module +======================== + +.. automodule:: lesana.collection + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/reference/lesana.command.rst b/docs/source/reference/lesana.command.rst new file mode 100644 index 0000000..729ec1d --- /dev/null +++ b/docs/source/reference/lesana.command.rst @@ -0,0 +1,7 @@ +lesana.command module +===================== + +.. automodule:: lesana.command + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/reference/lesana.data.rst b/docs/source/reference/lesana.data.rst new file mode 100644 index 0000000..fdbd552 --- /dev/null +++ b/docs/source/reference/lesana.data.rst @@ -0,0 +1,7 @@ +lesana.data package +=================== + +.. automodule:: lesana.data + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/reference/lesana.rst b/docs/source/reference/lesana.rst new file mode 100644 index 0000000..bab9655 --- /dev/null +++ b/docs/source/reference/lesana.rst @@ -0,0 +1,24 @@ +lesana package +============== + +.. automodule:: lesana + :members: + :undoc-members: + :show-inheritance: + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + lesana.data + +Submodules +---------- + +.. toctree:: + :maxdepth: 4 + + lesana.collection + lesana.command diff --git a/docs/source/reference/modules.rst b/docs/source/reference/modules.rst new file mode 100644 index 0000000..1ce51bd --- /dev/null +++ b/docs/source/reference/modules.rst @@ -0,0 +1,7 @@ +lesana reference +================ + +.. toctree:: + :maxdepth: 4 + + lesana -- cgit v1.2.3 From 8453c268f55ef7cfbc2fe6a6bc5c8ca7a67c8880 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 1 Oct 2020 23:04:58 +0200 Subject: Moved misc docs to sphinx --- docs/getting_started_command_line.rst | 61 ------------------------ docs/moving_data_between_collections.rst | 40 ---------------- docs/promises.rst | 35 -------------- docs/source/getting_started_command_line.rst | 62 +++++++++++++++++++++++++ docs/source/index.rst | 4 ++ docs/source/moving_data_between_collections.rst | 41 ++++++++++++++++ docs/source/promises.rst | 36 ++++++++++++++ 7 files changed, 143 insertions(+), 136 deletions(-) delete mode 100644 docs/getting_started_command_line.rst delete mode 100644 docs/moving_data_between_collections.rst delete mode 100644 docs/promises.rst create mode 100644 docs/source/getting_started_command_line.rst create mode 100644 docs/source/moving_data_between_collections.rst create mode 100644 docs/source/promises.rst diff --git a/docs/getting_started_command_line.rst b/docs/getting_started_command_line.rst deleted file mode 100644 index d2e4378..0000000 --- a/docs/getting_started_command_line.rst +++ /dev/null @@ -1,61 +0,0 @@ -Getting Started (Command Line) -============================== - -lesana can be used from the command line through the ``lesana`` command; -for more details run ``lesana help``. - -Many commands will try to open some file in an editor: they will attempt -to use, in this order, ``$EDITOR``, ``sensible-editor`` or as a fallback -``vi``, which should be installed on any POSIX-like system. - -To start a new collection, create a directory and run ``lesana -init`` into it:: - - mkdir $DIRECTORY - cd $DIRECTORY - lesana init - -It will create the basic file structure of a lesana collection, -including a ``settings.yaml`` skeleton and it will initialize a git -repository (use ``--no-git`` to skip this part and ignore all further -git commands). - -It will then open ``settings.yaml`` in an editor: fill in your list of -fields and all other data, save and exit. -You are now ready to commit the configuration for your new collection:: - - git commit -m 'Collection settings' - -An empty collection is not very interesting: let us start adding new -entries:: - - lesana new - -It will again open an editor on a skeleton of entry where you can fill -in the values. When you close the editor it will print the entry id, -that you can use e.g. to edit again the same entry:: - - lesana edit $ENTRY_ID - -After you've added a few entries, you can now search for some word that -you entered in one of the indexed fields:: - - lesana search some words - -this will also print the entry ids of matching items, so that you can -open them with ``lesana edit``. - -If you're using git, entries will be autoadded to the staging area, but -you need to commit them, so that you can choose how often you do so. - -Search results are limited by default to 12 matches; to get all results -for your query you can use the option ``--all``. This is especially -useful when passing the results to a template:: - - lesana search --template templates/my_report.html --all \ - some search terms \ - > some_search_terms-report.html - -will generate an html file based on the jinja2 template -``templates/my_report.html`` with all the entries found for those search -terms. diff --git a/docs/moving_data_between_collections.rst b/docs/moving_data_between_collections.rst deleted file mode 100644 index 170b391..0000000 --- a/docs/moving_data_between_collections.rst +++ /dev/null @@ -1,40 +0,0 @@ -Moving Data between Collections -=============================== - -Entries can be exported from a lesana collection to another using the -``lesana export`` command and a jinja2 template. - -The template should generate a yaml file that is a valid lesana entry -for the destination collection and it can use the fields of the starting -collection as variables. The variable ``entry`` is also available and -gives complete access to the entry of the original collection, so fields -with names that aren't valid jinja templates can be accessed as -``entry.data[]``. - -E.g. to convert between a collection with fields ``name``, -``short-desc``, ``desc`` to a collection with fields ``name``, -``description`` one could use the following template:: - - name: {{ name }} - description: | - {{ entry.data.[short-desc] }} - - {{ desc | indent(width=4, first=False) }} - -From the origin collection you can then run the command:: - - lesana export - -to export all entries. - -You can also export just a subset of entries by adding a xapian query -with the parameter ``--query``; you can test the search using:: - - lesana search --all - -and then actually run the export with:: - - lesana search --query ''