################ Developer Manual ################ .. note:: All commands listed in this manual are for `Debian `__ and `its derivations `__. ************ Technologies ************ NOFAInsert is a `QGIS `__ plugin written in `Python `__. Like other `QGIS `__ `Python `__ plugins it uses `QGIS API `__ and `PyQt `__ bindings. Additionally NOFAInsert plugin makes extensive use of `psycopg `__ package. Documentation ============= The newest version of plugin was developed for `QGIS `__ 2.18. * `QGIS 2.18 API `__ * `PyQt4 `__ * `psycopg2 `__ * `unittest `__ * `nose `__ * `coverage `__ *********** Development *********** History ======= In December 2016 Stefan Blumentrath (`GitHub profile `__) started developing the plugin. At the beggining of 2017 Matteo De Stefano (`GitHub profile `__) created a separate repository and released version `0.3 `__. Together with intern Jakob Miksch (`GitHub profile `__) who worked in `NINA `__ as part of his `Erasmus+ Internship `__ version `0.4 `__ was released. Another Erasmus+ intern Ondřej Svoboda (`GitHub profile `__) reworked the whole plugin and released version `0.5 `__. Current version is `0.5.2 `__. Development Tools Setup ======================= There is nothing a developer must setup in order to start (except for building :ref:`documentation `) because all needed `Python `__ packages are already present in `QGIS `__ by default. However, if you are using an IDE you can set it up to understand the API. * `Making Eclipse understand the API `__ .. _api-documentation: API Documentation ================= All classes, methods and functions are documented in `reStructuredText `__ format that can be used by `Sphinx `__ to generate documentation. * :ref:`API ` Debugging ========= * `Debugging using Eclipse and PyDev `__ Branches ======== There are three important branches: * **master** – main branch. * **gh-pages** – branch with :ref:`documentation `. * **before_rework_2017-07-13** – version `0.5 `__ came with significant changes. This branch serves as a backup of the previous version. Plugin Structure ================ Structure with short comments is as follows: :: / ├── data/ │ └── icons/ │ └── options.png # icon for opening connection parameters dialog ├── docs/ # directory with docs │ ├── source/ # directory with docs source │ ├── make.bat # batch file for creating docs │ ├── Makefile # makefile for creating docs │ └── update-docs.sh # bash script for publishing updates docs ├── nofa/ # NOFA package │ ├── gui/ # GUI package │ │ ├── __init__.py # module for package initialization │ │ ├── con_dlg.py # module with connection dialog class │ │ ├── de.py # module with custom date edit class │ │ ├── dtst_dlg.py # module with reference dialog class │ │ ├── exc.py # module with custom exceptions │ │ ├── ins_mw.py # module with insert main window class │ │ ├── ins_mw.ui # XML file for creating GUI │ │ ├── prj_dlg.py # module with project dialog class │ │ ├── ref_dlg.py # module with reference dialog class │ │ └── vald.py # module with custom validators │ ├── wms/ # directory with WMS files │ │ └── osm.xml # XML file for loading OSM basemap │ ├── __init__.py # module for package initialization │ ├── db.py # module with database queries │ └── ordered_set.py # module with OrderedSet container ├── scripts/ # directory with scripts │ └── create_log_tbls.py # script for creating log tables ├── test/ # directory with tests ├── __init__.py # module for package initialization ├── LICENSE # license file ├── Makefile # makefile ├── metadata.txt # plugin metadata ├── nofainsert.png # PNG plugin icon 64x64 pixels ├── nofainsert.svg # SVG plugin icon ├── nofa_insert.py # module with main class ├── nofainsert-24.png # PNG plugin icon 24x24 pixels └── README.md # GitHub readme NINA QGIS Plugin Repository =========================== Users install NOFAInsert plugin from NINA QGIS Plugin Repository. It is a simple `XML `__ file: * http://vm-srv-finstad.vm.ntnu.no/NOFA_plugins/plugins.xml When new version of plugin is released it is necessary to edit the file so that users get a notification. .. note:: How soon a user gets notified depends on his/her settings in :guilabel:`Plugins` :menuselection:`-->` :guilabel:`Manage and Install Plugins...` :menuselection:`-->` :guilabel:`Settings`. To adjust the file log in to server and edit ``version="0.5.2"`` to the new version. .. code-block:: bash ssh @vm-srv-finstad.vm.ntnu.no cd /var/www/html/NOFA_plugins nano plugins.xml .. note:: Version listed in http://vm-srv-finstad.vm.ntnu.no/NOFA_plugins/plugins.xml should match version in :file:`metadata.txt`. Don't forget to edit documentation. .. _online-documentation: Online Documentation ==================== Plugin documentation is available on its own `webpage `__. This webpage is connected to `gh-pages `__ branch. The documentation itself is written in `reStructuredText `__ and built with `Sphinx `__. First install `Sphinx `__ and `Read the Docs Theme `__: .. code-block:: bash sudo pip install sphinx sudo pip install sphinx_rtd_theme .. note:: To run commands mentioned above you need to have ``pip`` installed. .. code-block:: bash sudo apt install python-pip Then you can build the documentation: .. code-block:: bash cd docs/ make html .. warning:: If you run across a problem building the documentation (especially :ref:`API documentation `) make sure you run `Sphinx `__ for `Python `__ 2. To view created pages in `Firefox `__: .. code-block:: bash firefox build/html/index.html & When you are satisfied with your changes publish updated documentation to `gh-pages `__ branch by calling a script. .. code-block:: bash ./docs/update-docs.sh .. hint:: Call the script from plugin main directory. Testing ======= Unfortunately NOFAInsert plugin was not developed by using `test-driven development `__ so test were written later. That means there are not as many test as there should be. .. todo:: Write tests for: * :guilabel:`Location Table` * :guilabel:`Occurrence Table` * :guilabel:`Dataset` :guilabel:`Project` and :guilabel:`Reference` windows * inserting new :guilabel:`Dataset` :guilabel:`Project` and :guilabel:`Reference` * :guilabel:`Reset` button * :guilabel:`Insert to NOFA` button * :guilabel:`History` tab After trying to make `QGIS Tester Plugin `__ work and considering `QGIS Desktop for Docker `__ it was decided to use `unittest `__ framework and `nose `__ extension. On top of that `coverage `__ tool is used for an overview of how much code is tested. First install all required packages: .. code-block:: bash sudo pip install nose sudo pip install coverage To run tests execute this command from plugin main directory: .. code-block:: bash make test GitHub Repository ================= * `GitHub repository – Code `__ * `GitHub repository – Issues `__