Skip to content

Commit

Permalink
Merge pull request #10684 from camptocamp/backport/10681-to-2.7
Browse files Browse the repository at this point in the history
[Backport 2.7] Fix doccumentation issues
  • Loading branch information
sbrunner authored Sep 26, 2023
2 parents 57e05f7 + 8b2d08a commit 8ff4aeb
Show file tree
Hide file tree
Showing 22 changed files with 862 additions and 331 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MAJOR_VERSION ?= $(shell scripts/get-version --major)
MAJOR_MINOR_VERSION ?= $(shell scripts/get-version --major-minor)
VERSION ?= $(shell scripts/get-version --full)
MAIN_BRANCH ?= fake-local-branch
DOCKER_TAG ?= latest
export DOCKER_BUILDKIT=1

Expand Down Expand Up @@ -121,4 +122,4 @@ doc: build-tools ## Generate the documentation
--build-arg=MAJOR_VERSION=$(MAJOR_VERSION) \
--build-arg=MAIN_BRANCH=$(MAIN_BRANCH) \
doc
MAJOR_VERSION=$(MAJOR_VERSION) MAIN_BRANCH=$(MAIN_BRANCH) ci/extract-documentation artifacts/documentations/
ci/extract-documentation artifacts/documentations/
6 changes: 1 addition & 5 deletions ci/extract-documentation
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash -eux

mkdir --parent ${1}
docker build --tag=camptocamp/geomapfish-doc \
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} \
--build-arg=MAIN_BRANCH=${MAIN_BRANCH} \
doc
mkdir --parent "${1}"
docker run --rm --name=doc --detach camptocamp/geomapfish-doc tail -f /dev/null
docker cp doc:/doc/_build/html/ ${1}/
docker stop doc
11 changes: 6 additions & 5 deletions doc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ WORKDIR /doc
ARG MAJOR_VERSION
ARG MAIN_BRANCH

RUN ./import_ngeo_config.py --type Configuration integrator/ngeo_configuration.rst \
--type APIConfig integrator/ngeo_api_configuration.rst \
node_modules/ngeo/dist/typedoc.json integrator/ngeo_other_configuration.rst && \
RUN ./import_ngeo_config.py \
--type Configuration /ngeo_configuration.rst \
--type APIConfig /ngeo_api_configuration.rst \
node_modules/ngeo/dist/typedoc.json /ngeo_other_configuration.rst && \
mv integrator/ngeo_config_ref.rst / && \
mkdir --parent _build/html && \
sphinx-build -b html -d _build/doctrees . _build/html && \
./build.sh
sphinx-build -W -b html -d _build/doctrees . _build/html
7 changes: 1 addition & 6 deletions doc/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Sphinx-Substitution-Extensions = { extras = [
"prompt"
], version = "==2022.2.16" }
sphinxcontrib-mermaid = "==0.7.1"
#tilecloud-chain = "==1.17.0.dev20220131092647"
tilecloud-chain = "==1.17.4"
# Lock dependencies
babel = "==2.9.1"
certifi = "==2023.7.22"
Expand All @@ -32,12 +32,7 @@ pytz = "==2021.3"
pyyaml = "==6.0.1"
requests = "==2.31.0"
snowballstemmer = "==2.2.0"
sphinxcontrib-applehelp = "==1.0.7"
sphinxcontrib-devhelp = "==1.0.5"
sphinxcontrib-htmlhelp = "==2.0.4"
sphinxcontrib-jsmath = "==1.0.1"
sphinxcontrib-qthelp = "==1.0.6"
sphinxcontrib-serializinghtml = "==1.1.9"
urllib3 = "==1.26.16"
venusian = "==3.0.0"
webob = "==1.8.7"
Expand Down
501 changes: 492 additions & 9 deletions doc/Pipfile.lock

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions doc/build.sh

This file was deleted.

6 changes: 5 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@
# 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 = {"github_user": "camptocamp", "github_repo": "c2cgeoportal", "github_banner": True}
html_theme_options = {
"github_user": "camptocamp",
"github_repo": "c2cgeoportal",
"github_banner": False,
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down
6 changes: 5 additions & 1 deletion doc/import_ngeo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def main() -> None:
"""Convert the ngeo config to ReStructuredText."""
parser = argparse.ArgumentParser("Convert the config from the JSON from typedoc to ReStructuredText")
parser.add_argument(
"--type", help="create a separate file for a type", nargs=2, action="append", default=[]
"--type",
help="create a separate file for a type",
nargs=2,
action="append",
default=[],
)
parser.add_argument("input", help="the JSON file from typedoc")
parser.add_argument("other", help="filename for other types")
Expand Down
18 changes: 8 additions & 10 deletions doc/integrator/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ application's main ``__init__.py`` file.

In the file ``env.project``, you can configure the policy with the following variables:

.. code::
AUTHTKT_TIMEOUT # Default to one day.
AUTHTKT_REISSUE_TIME # Default to 2h30, recommended to be 10 times smaller than AUTHTKT_TIMEOUT.
AUTHTKT_MAXAGE # Default to one day, good to have the same value as AUTHTKT_TIMEOUT.
AUTHTKT_SECRET # Should be defined
AUTHTKT_COOKIENAME
AUTHTKT_HTTP_ONLY # Default to true.
AUTHTKT_SECURE # Default to true.
AUTHTKT_SAMESITE # Default to Lax.
``AUTHTKT_TIMEOUT``: Default to one day.
``AUTHTKT_REISSUE_TIME``: Default to 2h30, recommended to be 10 times smaller than ``AUTHTKT_TIMEOUT``.
``AUTHTKT_MAXAGE``: Default to one day, good to have the same value as ``AUTHTKT_TIMEOUT``.
``AUTHTKT_SECRET``: Should be defined
``AUTHTKT_COOKIENAME``: Should be defined
``AUTHTKT_HTTP_ONLY``: Default to ``true``.
``AUTHTKT_SECURE``: Default to ``true``.
``AUTHTKT_SAMESITE``: Default to ``Lax``.

.. note::

Expand Down
181 changes: 91 additions & 90 deletions doc/integrator/create_application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,25 +340,27 @@ it can be obtained with:

In the `Makefile` you should add something like:

```
DUMP_FILE=dump.backup

.PHONY: acceptance-init
acceptance-init: ## Initialize the acceptance tests
docker-compose --file=docker-compose.yaml --file=docker-compose-db.yaml up -d
docker-compose exec -T geoportal wait-db
docker-compose exec -T tools psql --command="DROP EXTENSION IF EXISTS postgis CASCADE"
scripts/db-restore --docker-compose-file=docker-compose.yaml --docker-compose-file=docker-compose-db.yaml \
--arg=--clean --arg=--if-exists --arg=--verbose $(DUMP_FILE)

.PHONY: acceptance
acceptance: ## Run the acceptance tests
docker-compose exec -T tools pytest -vv tests/
```
.. code:: make
DUMP_FILE=dump.backup
.PHONY: acceptance-init
acceptance-init: ## Initialize the acceptance tests
docker-compose --file=docker-compose.yaml --file=docker-compose-db.yaml up -d
docker-compose exec -T geoportal wait-db
docker-compose exec -T tools psql --command="DROP EXTENSION IF EXISTS postgis CASCADE"
scripts/db-restore --docker-compose-file=docker-compose.yaml --docker-compose-file=docker-compose-db.yaml \
--arg=--clean --arg=--if-exists --arg=--verbose $(DUMP_FILE)
.PHONY: acceptance
acceptance: ## Run the acceptance tests
docker-compose exec -T tools pytest -vv tests/
In the file `.github/workflows/main.yaml` you should add something like:

```yaml
.. code:: yaml
- name: Initialize the acceptance tests
run: make acceptance-init
- run: c2cciutils-docker-logs
Expand All @@ -369,83 +371,82 @@ In the file `.github/workflows/main.yaml` you should add something like:
- run: c2cciutils-docker-logs
if: always()
```

You should add a `docker-compose-db.yaml` file, with:

```
# This file is used by the acceptance tests to have a local database.

version: '2.3'

volumes:
postgresql_data:

services:
config: &db-config
environment:
- PGHOST=db
- PGHOST_SLAVE=db
- PGSSLMODE=prefer
geoportal: *db-config
# geoportal-advance: *db-config
tools: *db-config
alembic: *db-config
# alembic-advance: *db-config
# webpack_dev_server: *db-config
db:
extends:
file: docker-compose-lib.yaml
service: db
.. code:: yaml
# This file is used by the acceptance tests to have a local database.
version: '2.3'
volumes:
- postgresql_data:/var/lib/postgresql/data
```
postgresql_data:
services:
config: &db-config
environment:
- PGHOST=db
- PGHOST_SLAVE=db
- PGSSLMODE=prefer
geoportal: *db-config
# geoportal-advance: *db-config
tools: *db-config
alembic: *db-config
# alembic-advance: *db-config
# webpack_dev_server: *db-config
db:
extends:
file: docker-compose-lib.yaml
service: db
volumes:
- postgresql_data:/var/lib/postgresql/data
And finally the file with the tests `tests/test_app.py` with:

```
import time
from typing import Dict

import pytest
import requests


@pytest.mark.parametrize(
"url,params",
[
("https://front", {}),
("https://front/themes", {}),
("https://front/static-geomapfish/0/locales/fr.json", {}),
("https://front/dynamic.json", {"interface": "desktop"}),
("https://front/dynamic.json", {"interface": "desktop", "query": "", "path": "/"}),
("https://front/c2c/health_check", {}),
("https://front/c2c/health_check", {"max_level": "1"}),
("https://front/c2c/health_check", {"checker": "check_collector"}),
("https://front/admin/layertree", {}),
("https://front/admin/layertree/children", {}),
("http://mapserver:8080/mapserv_proxy", {"SERVICE": "WMS", "REQUEST": "GetCapabilities"}),
(
"https://front/mapserv_proxy",
{"ogcserver": "source for image/png", "SERVICE": "WMS", "REQUEST": "GetCapabilities"},
),
],
)
def test_url(url: str, params: Dict[str, str]) -> None:
"""Tests that some URL didn't return an error."""
for _ in range(60):
response = requests.get(url, params=params, verify=False, timeout=240) # nosec
if response.status_code == 503:
time.sleep(1)
continue
break
assert response.status_code == 200, response.text


def test_admin() -> None:
"""Tests that the admin page will provide the login page."""
response = requests.get("https://front/admin/", verify=False, timeout=240) # nosec
assert response.status_code == 200, response.text
assert "Login" in response.text
```
.. code:: python
import time
from typing import Dict
import pytest
import requests
@pytest.mark.parametrize(
"url,params",
[
("https://front", {}),
("https://front/themes", {}),
("https://front/static-geomapfish/0/locales/fr.json", {}),
("https://front/dynamic.json", {"interface": "desktop"}),
("https://front/dynamic.json", {"interface": "desktop", "query": "", "path": "/"}),
("https://front/c2c/health_check", {}),
("https://front/c2c/health_check", {"max_level": "1"}),
("https://front/c2c/health_check", {"checker": "check_collector"}),
("https://front/admin/layertree", {}),
("https://front/admin/layertree/children", {}),
("http://mapserver:8080/mapserv_proxy", {"SERVICE": "WMS", "REQUEST": "GetCapabilities"}),
(
"https://front/mapserv_proxy",
{"ogcserver": "source for image/png", "SERVICE": "WMS", "REQUEST": "GetCapabilities"},
),
],
)
def test_url(url: str, params: Dict[str, str]) -> None:
"""Tests that some URL didn't return an error."""
for _ in range(60):
response = requests.get(url, params=params, verify=False, timeout=240) # nosec
if response.status_code == 503:
time.sleep(1)
continue
break
assert response.status_code == 200, response.text
def test_admin() -> None:
"""Tests that the admin page will provide the login page."""
response = requests.get("https://front/admin/", verify=False, timeout=240) # nosec
assert response.status_code == 200, response.text
assert "Login" in response.text
1 change: 1 addition & 0 deletions doc/integrator/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ For OpenShift projects:
tinyows -.-> postgres;

classDef data fill:#5ba6ff,color:black;

For standalone projects:

.. mermaid::
Expand Down
2 changes: 1 addition & 1 deletion doc/integrator/extend_application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ For that you will need to create a new folder named ``geoportal_custom``.

An this folder, add a file named ``authentication.py`` with the content you need, the original content is:

.. code:: python:
.. code:: python
from pyramid.config import Configurator
Expand Down
2 changes: 1 addition & 1 deletion doc/integrator/headers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You may wish to override the values being written. All this is done in the confi
cache_control_max_age: 600 # 10 minutes
access_control_max_age: 600 # 10 minutes
access_control_allow_origin: [] # list oh hosts (e.g. https://example.com) or '*'
headers: {} @ list of additional headers
headers: {} # list of additional headers
Where ``<view>`` can be: ``dynamic``, ``index``, ``api``, ``apihelp``, ``profile``, ``raster``, ``error``,
``themes``, ``config``, ``print``, ``fulltextsearch``, ``mapserver``, ``tinyows``, ``layers``,
Expand Down
9 changes: 5 additions & 4 deletions doc/integrator/https.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-----
HTTPS
-----

Expand All @@ -12,7 +13,7 @@ There are two ways to manage this:
* application and SSL certificate on the same server

Application behind a proxy
~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------

If the application is placed behind some proxy that removes the SSL encryption
(plain HTTP is used between the proxy and the server), then some specific
Expand All @@ -35,7 +36,7 @@ value of ``request.scheme``. For example::
};

Application and SSL certificate on the same server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------------

If the SSL certificate and the application are located on the same server, all
requests will be redirected to https. So you should change the scheme to https
Expand All @@ -52,7 +53,7 @@ In case you load http external resources into your application, you should use
the resourceproxy service as described below.

Loading non https external resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------

If you want to load non https external resources in your https application, you
should use the ``resourceproxy`` service and add the list of hosts you want to access in your project
Expand All @@ -74,7 +75,7 @@ For example:
``https://geoportail.camptocamp.com/main/resourceproxy?target=rfinfo&values=(175,2633)``

Local certificate checks
~~~~~~~~~~~~~~~~~~~~~~~~
------------------------

Certain c2cgeoportal features open a http session to your c2cgeoportal services,
for example the ``checker`` or the ``lingua_extractor``.
Expand Down
Loading

0 comments on commit 8ff4aeb

Please sign in to comment.