From a4e10e256c36d4fddc808d8abc58ed6175ed93a0 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Wed, 30 Aug 2023 17:40:36 +0200 Subject: [PATCH] Adding documentation --- .gitignore | 2 +- docs/Makefile | 20 ++++++++++++++++++ docs/conf.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 51 ++++++++++++++++++++++++++++++++++++++++++++++ docs/make.bat | 35 ++++++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/.gitignore b/.gitignore index 311f12d..94d8e79 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,5 @@ replay_pid* /.project /.settings /gcat/ -/.DS_Store +**.DS_Store /bin/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /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 = . +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/conf.py b/docs/conf.py new file mode 100644 index 0000000..9f6e464 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,55 @@ +# 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 = 'Software Versions Processor Lib' +copyright = '2023, Luca Frosini (ISTI-CNR)' +author = 'Luca Frosini (ISTI-CNR)' + +# The full version, including alpha/beta/rc tags +# release = '6.0.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 = [] + +# 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 = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- 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 = 'sphinx_rtd_theme' +html_theme = 'sphinxdoc' + +# 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'] \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..c4e7314 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,51 @@ +This library has been initially designed to deposit software artifacts programmatically in Zenodo. + +It is actually a general-purpose library capable of analyzing a list of +software artifacts (represented by the metadata) and export them. + +The library currently offers two exporters: + +* **ZenodoExporter**: deposit the software artifact in Zenodo obtaining a DOI; +* **BibLaTeXExporter**: export the software artifact in a ``bib`` file using the BibLaTeX format. + +Other exporters can be easily added in the future by extending the ``SoftwareVersionExporter`` class. + +The core class of the library is Analyser, which must be initialized with: + +* a configuration (JSON Object); +* a list of software artifacts described by their metadata (JSON Array). + +The configuration must contain the list of exporters to be used and their configuration parameters. +Exporter configuration requires the 'elaboration' property, which can assume the following values +(see ``ElaborationType`` enumerated): + +* **ALL**: The exporter analyses all the software artifacts; +* **UPDATE_ONLY**: The exporter analyes only the software artifact to be updated in the target. +* **NEW**: The exporter analyses only the software artifact that does not yet exist in the target. +* **NONE**: Does not export the software artifact in the target, but each software artifact is elaborated for the exporting without effectively doing it. It is a dry run. + +The exporters are executed in the order they are defined. +An exporter could produce metadata obtained by the exporting phase (e.g., the obtained Zenodo DOI). +The input metadata + the metadata generated by an exporter are made available to the subsequent. + +At the end of the exporting phase, the library produces the actual output of all the software artifact metadata. + +Moreover, the configuration can optionally include an arbitrary set of metadata used as metadata default for all software artifacts defined in the list. + +The list of software artifacts can contain an arbitrary set of metadata. +It is the exporter logic that uses certain metadata, among others. + +While analyzing each software artifact, the ``Analyser`` set the previous to the exporter. +Relating the artifact with the previous one is helpful if an exporter needs to link them. +It is in charge of the exporter's logic of eventually connecting them under specific metadata values used as conditions. + +The library dynamically calculates the value of metadata to elaborate using the following essential features: + +* A property can contain the value of another property indicated as a variable using the referred property name; +* The library merges the metadata of the software artifact with the metadata defined in the configuration; +* The library calculates the final metadata values, replacing the variables only after merging the properties. + +The following example show an example of configuration + +.. literalinclude:: ../src/test/resources/gcat-test-sandbox.json + :language: JSON \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..153be5e --- /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=. +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.https://www.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