Skip to content

Commit

Permalink
Merge pull request #3503 from lonvia/mkdocs-without-cmake
Browse files Browse the repository at this point in the history
Build documentation without CMake
  • Loading branch information
lonvia authored Aug 7, 2024
2 parents 738e99c + d1e7b85 commit 882f182
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 150 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.swp

docs/develop/*.png
site-html

build
dist
Expand Down
18 changes: 0 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ set(BUILD_IMPORTER on CACHE BOOL "Build everything for importing/updating the da
set(BUILD_API on CACHE BOOL "Build everything for the API server")
set(BUILD_MODULE off CACHE BOOL "Build PostgreSQL module for legacy tokenizer")
set(BUILD_TESTS on CACHE BOOL "Build test suite")
set(BUILD_DOCS on CACHE BOOL "Build documentation")
set(BUILD_MANPAGE on CACHE BOOL "Build Manual Page")
set(BUILD_OSM2PGSQL on CACHE BOOL "Build osm2pgsql (expert only)")
set(INSTALL_MUNIN_PLUGINS on CACHE BOOL "Install Munin plugins for supervising Nominatim")

Expand Down Expand Up @@ -188,22 +186,6 @@ if (BUILD_MODULE)
add_subdirectory(module)
endif()

#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------

if (BUILD_DOCS)
add_subdirectory(docs)
endif()

#-----------------------------------------------------------------------------
# Manual page
#-----------------------------------------------------------------------------

if (BUILD_MANPAGE)
add_subdirectory(man)
endif()

#-----------------------------------------------------------------------------
# Installation
#-----------------------------------------------------------------------------
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@ lint:
bdd:
cd test/bdd; behave -DREMOVE_TEMPLATE=1

.PHONY: tests mypy pytest lint bdd build clean-build build-db build-api
# Documentation

doc:
mkdocs build

serve-doc:
mkdocs serve

manpage:
argparse-manpage --pyfile man/create-manpage.py --function get_parser --project-name Nominatim --url https://nominatim.org > man/nominatim.1 --author 'the Nominatim developer community' --author-email [email protected]


.PHONY: tests mypy pytest lint bdd build clean-build build-db build-api doc serve-doc manpage
35 changes: 0 additions & 35 deletions docs/CMakeLists.txt

This file was deleted.

4 changes: 2 additions & 2 deletions docs/admin/Deployment-Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ to configure it.
### Installing the required packages

The Nominatim frontend is best run from its own virtual environment. If
you have already created one for the database backend during
[installation](Installation.md#Building-Nominatim), you can use that. Otherwise
you have already created one for the database backend during the
[installation](Installation.md#building-nominatim), you can use that. Otherwise
create one now with:

```sh
Expand Down
4 changes: 2 additions & 2 deletions docs/admin/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This page contains generic installation instructions for Nominatim and its
prerequisites. There are also step-by-step instructions available for
the following operating systems:

* [Ubuntu 24.04](../appendix/Install-on-Ubuntu-24.md)
* [Ubuntu 22.04](../appendix/Install-on-Ubuntu-22.md)
* [Ubuntu 24.04](Install-on-Ubuntu-24.md)
* [Ubuntu 22.04](Install-on-Ubuntu-22.md)

These OS-specific instructions can also be found in executable form
in the `vagrant/` directory.
Expand Down
7 changes: 0 additions & 7 deletions docs/bash2md.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docs/customize/Tokenizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ NOMINATIM_DATABASE_MODULE_PATH=<path to directory where nominatim.so resides>
```

This is in particular useful when the database runs on a different server.
See [Advanced installations](../admin/Advanced-Installations.md#importing-nominatim-to-an-external-postgresql-database) for details.
See [Advanced installations](../admin/Advanced-Installations.md#using-an-external-postgresql-database) for details.

There are no other configuration options for the legacy tokenizer. All
normalization functions are hard-coded.
Expand Down
17 changes: 7 additions & 10 deletions docs/develop/Development-Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The documentation is built with mkdocs:
* [mkdocs](https://www.mkdocs.org/) >= 1.1.2
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.25
* [mkdocs-material](https://squidfunk.github.io/mkdocs-material/)
* [mkdocs-gen-files](https://oprypin.github.io/mkdocs-gen-files/)

Please be aware that tests always run against the globally installed
osm2pgsql, so you need to have this set up. If you want to test against
Expand All @@ -66,9 +67,9 @@ To set up the virtual environment with all necessary packages run:
```sh
virtualenv ~/nominatim-dev-venv
~/nominatim-dev-venv/bin/pip install\
psycopg2-binary psutil psycopg[binary] PyICU SQLAlchemy \
python-dotenv jinja2 pyYAML datrie \
behave mkdocs mkdocstrings pytest pytest-asyncio pylint \
psutil psycopg[binary] PyICU SQLAlchemy \
python-dotenv jinja2 pyYAML datrie behave \
mkdocs mkdocstrings mkdocs-gen-files pytest pytest-asyncio pylint \
types-jinja2 types-markupsafe types-psutil types-psycopg2 \
types-pygments types-pyyaml types-requests types-ujson \
types-urllib3 typing-extensions unicorn falcon
Expand Down Expand Up @@ -147,18 +148,14 @@ built using the [MkDocs](https://www.mkdocs.org/) static site generation
framework. The master branch is automatically deployed every night on
[https://nominatim.org/release-docs/develop/](https://nominatim.org/release-docs/develop/)

To build the documentation, go to the build directory and run
To build the documentation run

```
make doc
INFO - Cleaning site directory
INFO - Building documentation to directory: /home/vagrant/build/site-html
```

This runs `mkdocs build` plus extra transformation of some files and adds
symlinks (see `CMakeLists.txt` for the exact steps).

Now you can start webserver for local testing
For local testing, you can start webserver:

```
build> make serve-doc
Expand All @@ -170,7 +167,7 @@ If you develop inside a Vagrant virtual machine, use a port that is forwarded
to your host:

```
build> PYTHONPATH=$SRCDIR mkdocs serve --dev-addr 0.0.0.0:8088
build> mkdocs serve --dev-addr 0.0.0.0:8088
[server:296] Serving on http://0.0.0.0:8088
[handlers:62] Start watching changes
```
4 changes: 2 additions & 2 deletions docs/library/Input-Parameter-Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ in the query functions of the API object.

## Place identification

The [details](NominatimAPI.md#nominatim_api.core.NominatimAPI.details) and
[lookup](NominatimAPI.md#nominatim_api.core.NominatimAPI.lookup) functions
The [details](NominatimAPI.md#nominatim_api.NominatimAPI.details) and
[lookup](NominatimAPI.md#nominatim_api.NominatimAPI.lookup) functions
require references to places in the database. Below the possible
types for place identification are listed. All types are dataclasses.

Expand Down
32 changes: 32 additions & 0 deletions docs/mk_install_instructions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of Nominatim. (https://nominatim.org)
#
# Copyright (C) 2024 by the Nominatim developer community.
from pathlib import Path

import mkdocs_gen_files

VAGRANT_PATH = Path(__file__, '..', '..', 'vagrant').resolve()

for infile in VAGRANT_PATH.glob('Install-on-*.sh'):
outfile = f"admin/{infile.stem}.md"
title = infile.stem.replace('-', ' ')

with mkdocs_gen_files.open(outfile, "w") as outfd, infile.open() as infd:
print("#", title, file=outfd)
has_empty = False
for line in infd:
line = line.rstrip()
docpos = line.find('#DOCS:')
if docpos >= 0:
line = line[docpos + 6:]
elif line == '#' or line.startswith('#!'):
line = ''
elif line.startswith('# '):
line = line[2:]
if line or not has_empty:
print(line, file=outfd)
has_empty = not bool(line)

mkdocs_gen_files.set_edit_path(outfile, "docs/mk_install_instructions.py")
15 changes: 0 additions & 15 deletions man/CMakeLists.txt

This file was deleted.

12 changes: 12 additions & 0 deletions man/create-manpage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
import os
from pathlib import Path

sys.path.append(str(Path(__file__, '..', '..', 'src').resolve()))

from nominatim_db.cli import get_set_parser

def get_parser():
parser = get_set_parser()

return parser.parser
12 changes: 0 additions & 12 deletions man/create-manpage.tmpl

This file was deleted.

Loading

0 comments on commit 882f182

Please sign in to comment.