Skip to content

Commit

Permalink
build: make mkdocs strict on links (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel authored Oct 4, 2024
1 parent 6789e80 commit 4cb534a
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 18 deletions.
9 changes: 7 additions & 2 deletions app/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ def export_schema(

import yaml

from app.config import ConfigGenerateJsonSchema
from app.config import Config, ConfigGenerateJsonSchema, SettingsGenerateJsonSchema

schema = class_.model_json_schema(schema_generator=ConfigGenerateJsonSchema)
schema_generator = (
ConfigGenerateJsonSchema
if issubclass(class_, Config)
else SettingsGenerateJsonSchema
)
schema = class_.model_json_schema(schema_generator=schema_generator)

print("writing json schema")
with open(target_path, "w") as f:
Expand Down
10 changes: 10 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ def generate(self, schema, mode="validation"):
return json_schema


class SettingsGenerateJsonSchema(GenerateJsonSchema):
"""Config to add fields to generated JSON schema for Settings."""

def generate(self, schema, mode="validation"):
json_schema = super().generate(schema, mode=mode)
json_schema["title"] = "JSON schema for search-a-licious settings"
json_schema["$schema"] = self.schema_dialect
return json_schema


class TaxonomySourceConfig(BaseModel):
"""Configuration on how to fetch a particular taxonomy."""

Expand Down
1 change: 1 addition & 0 deletions docs/devs/ref-python/cli.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- This file will be generated and overwritten, it is needed as MkDocs checks links -->
6 changes: 3 additions & 3 deletions docs/users/explain-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ but is capable of serving multiple datasets

It provides a section for each index you want to create (corresponding to a dataset).

If you have more than one dataset, one must be declared the default (see [default_index](../ref-config/searchalicious-config-schema.html#default_index))
If you have more than one dataset, one must be declared the default (see [default_index](./ref-config/searchalicious-config-schema.html#default_index))

## Main sections

Expand Down Expand Up @@ -57,7 +57,7 @@ Think well about:

Changing this section will probably involve a full re-indexing of all your items.

Read more in the [reference documentation](../ref-config/searchalicious-config-schema.html#fields).
Read more in the [reference documentation](./ref-config/searchalicious-config-schema.html#fields).

## Document fetcher, pre-processors and post-processors

Expand All @@ -69,7 +69,7 @@ Search-a-licious offers a way for you to customize some critical operations usin
* whereas result_processor adapts each result returned by a search, keep it lightweight !
* document_fetcher is only used for continuous updates to fetch documents using an API

Read more in the [reference documentation](../ref-config/searchalicious-config-schema.html).
Read more in the [reference documentation](./ref-config/searchalicious-config-schema.html).

## Scripts

Expand Down
10 changes: 5 additions & 5 deletions docs/users/how-to-update-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ There are two strategies to update the index:
First import will populate Elasticsearch index with all the data.

See [*initial import* section in tutorial](./tutorial.md#initial-import)
and [`import` reference documentation](../ref-python/cli.html#python3-m-app-import)
and [`import` reference documentation](../devs/ref-python/cli.html#python3-m-app-import)

It's important to note that if you don't use the *continous updates* strategy,
you need to use `--skip-updates` option.
Expand All @@ -38,7 +38,7 @@ docker-compose up -d updater
This will continuously fetch updates from the event stream, and update the index accordingly.

At start it will compute last update time using
the [`last_modified_field_name` from the configuration](../ref-config/searchalicious-config-schema.html#indices_additionalProperties_index_last_modified_field_name)
the [`last_modified_field_name` from the configuration](./ref-config/searchalicious-config-schema.html#indices_additionalProperties_index_last_modified_field_name)
to know from where to start processing the event stream.

## Updating the index from time to time with an export
Expand All @@ -48,15 +48,15 @@ Another way to update the index is to periodically re-import the all the data, o
This is less compelling to your users, but this might be the best way
if you are using an external database publishing changes on a regular bases.

For that you can use the [`import` command](../ref-python/cli.html#python3-m-app-import),
For that you can use the [`import` command](../devs/ref-python/cli.html#python3-m-app-import),
with the `--skip-updates` option, and with the `--partial` option if you are importing only changed data
(otherwise it is advised to use the normal import process, which can be rolled-back (it create a new index)).

## Document fetcher and pre-processing

In the configuration, you can define a
[`document_fetcher`](../ref-config/searchalicious-config-schema.html#indices_additionalProperties_document_fetcher)
and a [`preprocessor`](../ref-config/searchalicious-config-schema.html#indices_additionalProperties_preprocessor) to transform the data.
[`document_fetcher`](./ref-config/searchalicious-config-schema.html#indices_additionalProperties_document_fetcher)
and a [`preprocessor`](./ref-config/searchalicious-config-schema.html#indices_additionalProperties_preprocessor) to transform the data.

Those are fully qualified dotted names to python classes.

Expand Down
2 changes: 1 addition & 1 deletion docs/users/how-to-use-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Here:
It's mostly a way to declare constants in the script.
(hopefully more convenient than declaring them in the script)

For more information on configuration for scripts see [configuration reference](../ref-config/searchalicious-config-schema.html#indices_additionalProperties_scripts)
For more information on configuration for scripts see [configuration reference](./ref-config/searchalicious-config-schema.html#indices_additionalProperties_scripts)

For informations on how to write scripts,
see [introduction to script in Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html)
Expand Down
Empty file removed docs/users/index.md
Empty file.
4 changes: 2 additions & 2 deletions docs/users/ref-config.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Reference for Configuration file

You can find the [raw json schema here](./searchalicious-config-schema.yml)
You can find the [raw json schema here](./ref-config/searchalicious-config-schema.yml)

[See configuration documentation on it's own page](./searchalicious-config-schema.html)
[See configuration documentation on it's own page](./ref-config/searchalicious-config-schema.html)
<iframe src="./searchalicious-config-schema.html" width="900vw" height="1000vh" style="max-width: 900px; max-height: 1000px;">
<!-- This iframe contains documentation generated by scripts/build_schema.sh -->
</iframe>
1 change: 1 addition & 0 deletions docs/users/ref-config/searchalicious-config-schema.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- This file will be generated and overwritten, it is needed as MkDocs checks links -->
1 change: 1 addition & 0 deletions docs/users/ref-config/searchalicious-config-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this file will be generated and overwritten, it is needed as MkDocs checks links
4 changes: 2 additions & 2 deletions docs/users/ref-settings.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Reference for Settings

You can find the [raw json schema here](./searchalicious-settings-schema.yml)
You can find the [raw json schema here](./ref-settings/searchalicious-settings-schema.yml)

[See Settings documentation on it's own page](./searchalicious-settings-schema.html)
[See Settings documentation on it's own page](./ref-settings/searchalicious-settings-schema.html)
<iframe src="./searchalicious-settings-schema.html" width="900vw" height="1000vh" style="max-width: 900px; max-height: 1000px;">
<!-- This iframe contains documentation generated by scripts/build_schema.sh -->
</iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- This file will be generated and overwritten, it is needed as MkDocs checks links -->
1 change: 1 addition & 0 deletions docs/users/ref-settings/searchalicious-settings-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this file will be generated and overwritten, it is needed as MkDocs checks links
2 changes: 0 additions & 2 deletions docs/users/searchalicious-config-schema.yml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/build_mkdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ docker build --build-arg "USER_UID=$UID" --build-arg "USER_GID=$GID" --tag 'mkdo
docker run --rm \
-e USER_ID=$UID -e GROUP_ID=$GID \
-v $(pwd):/app -w /app \
mkdocs-builder build
mkdocs-builder build --strict

0 comments on commit 4cb534a

Please sign in to comment.