Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have Conf module for generic configuration files working #103

Open
leovalais opened this issue Dec 13, 2018 · 0 comments
Open

Have Conf module for generic configuration files working #103

leovalais opened this issue Dec 13, 2018 · 0 comments

Comments

@leovalais
Copy link
Contributor

leovalais commented Dec 13, 2018

The idea is to have a declarative and generic way to describe what the configuration should contain, the type of the values, their default value, some checks, etc. and abstract away from the actual configuration format used.

That is, having an abstract & generic configuration declaration, say myconfig, one could read it from a YAML file using

Conf.(parse yaml_parser myconfig in_channel)

or from a JSON file using:

Conf.(parse json_parser myconfig in_channel)

This way, compatibility with dop is ensured but it lets html_of_wiki to have a more modern looking configuration file (such as hugoio or jekyll).

Part of the work has already be done (see #88).

Here is what the configuration file should contain (this is the content of some draft design file, better documentation can be found in what's already declared using Conf):

Les options en ligne de commande override les options du fichier de configuration.

** Options non-extensions
| Nom               | Type         | Valeur par défaut | Description                                             |
|-------------------+--------------+-------------------+---------------------------------------------------------|
| deploy            | bool         | false             | Liens locaux/déploiement + extension when-local         |
| templates         | string array | []                | Templates à inline dans l'ordre                         |
| versions          | string array | []                | Liste explicite des versions à gérer                    |
| build-dir         | string       | _build            | Nom du dossier de build.                                |
| remote            | string       | origin            | Nom de la remote pour le deploy                         |
| force             | bool         | false             | Force le build même sir le dossier de build existe déjà |
| commit-message    | string       | how deploy        |                                                         |
| link-check        | mapping      |                   |                                                         |
| link-check.raw    | bool         | false             |                                                         |
| link-check.silent | bool         | false             | A la priorité.                                          |

** Options d'extensions
| Nom                      | Type           | Valeur par défaut | Description                 |
|--------------------------+----------------+-------------------+-----------------------------|
| manual                   | string         |                   | Lien relatif vers le manuel |
| api                      | string/mapping |                   | Si string, == api.dir       |
| api.dir                  | string         |                   | Dossier de l'api            |
| api.client               | string         |                   | Vers le client              |
| api.server               | string         |                   | Vers le server              |
| api.default-subproject   | string         |                   |                             |
| assets                   | string/mapping |                   | Si string, ==assets.dir     |
| assets.dir               | string         |                   | Assets                      |
| assets.images            | string         |                   | Images spécifiquement       |
| menu                     | bool           |                   |                             |
| csw/client-server-switch | bool           |                   |                             |

What's already done:

html_of_wiki/src/how.ml

Lines 31 to 77 in e4314fd

let how_config : how_config_key Conf.elt =
Conf.(mapping [pair "deploy" `Deploy (bool () ~default:false)
~doc:"Builds the website for deployement purpose (instead of testing).";
pair "templates" `Templates (sequence (string ()
~check:Sys.file_exists
~err:"Template does not exist.")
~default:[])
~doc:"The list of templates, outermost first.";
pair "versions" `Versions (sequence (string ())
~check:(fun s -> s <> [])
(* ~default:(infer_versions ()) *)
~err:"Version list cannot be empty.")
~doc:"The list of version directories.";
pair "build-dir" `Build_dir (string () ~default:"_build")
~doc:"Name of the build directory.";
(* remote *)
pair "force" `Force (bool () ~default:false)
~doc:"Overwrites the build directory if it exists when the build starts.";
pair "link-check" `Link_check (mapping [pair "raw" `Raw (bool () ~default:false)
~doc:"Doesn't converts linkchecker's output to Json when true.";
pair "silent" `Silent (bool () ~default:false)
~doc:"No output at all when true."])
~doc:"Behaviour of the command `how check links'.";
pair "manual" `Manual (string () (* ~default:(infer_manual ()) *))
~doc:"Path to the manual directory.";
pair "api" `Api (either (string ())
(mapping [pair "dir" `Dir (string ())
~doc:"The path to the API directory.";
pair "client" `Client (string ())
~doc:"The path to the client API directory.";
pair "server" `Server (string ())
~doc:"The path to the server API directory.";
pair "default-subproject" `Def_subp (string ())
~doc:"Default subproject's name. Obsolete."]
(* ~default:(infer_api ()) *)))
~doc:"API information. When just a string, the path to the API directory.";
pair "assets" `Assets (either (string ())
(mapping [pair "dir" `Dir (string ())
~doc:"The path to the asset directory.";
pair "images" `Img (string ())
~doc:"The path to the image directory."]))
~doc:"Asset information. When just a string, the path to the image + asset directory.";
pair "menu" `Menu (bool () ~default:false)
~doc:"Whether to include or not a side menu (cf. doctree extension).";
pair "client-server-switch" `Csw (bool () ~default:false)
~doc:"Whether to include or not a client/server switch on compatible pages (cf. extension)."])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant