package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.kit/B0_init/index.html
Module B0_initSource
Generate files from templates.
Exposes, functions initially used by b0 init.
Likely needs a few design rounds. Some of the project lookup stuff could be migrated elsewhere. Eventually add something than can be easily extended via install dir lookups like carcass did.
Project metadata
find_project_meta () finds default metadata for the project. For now this the meta of B0_pack.find_default if there is a b0 file linked (see B0_driver.has_b0_file).
get_project_meta () is like find_project_meta but defaults to B0_meta.empty.
default_root_marker filenames that could denote the root of a project's source tree.
val find_project_name :
?root_markers:string list ->
cwd:B0_std.Fpath.t ->
unit ->
(string option, string) resultfind_project_name ~cwd () tries to determine a name for the project. This is either the basename of the VCS work directory or it loops up from the current working directory cwd trying to find a file a directory which has a file whose name is in root_markers which defaults to default_root_markers.
Copyrights
get_copyright_years years defaults the option to the current year, as determined by Unix.gettimeofday in UTC.
CHANGES files
The type for changes generators.
find_changes_generator f is a changes generator for a file file (ignored for now).
LICENSE files
find_project_license m looks the first B0_meta.licenses in meta.
get_project_license meta license defaults license with find_project_license or "ISC" if that didn't yield anything (author bias, open to a better scheme).
val download_license_template :
?httpc:B0_http.Http_client.t ->
strip_meta:bool ->
B0_meta.spdxid ->
(string, string) resultdownload_license_template spdxid tries to download a licence template for spdxid. The SPDX project doesn't seem to provide this. We rely on the data from choosealicense.com. strip_meta inidicates whether the YAML preamble should be stripped. httpc is the client to use, it default to B0_http.Http_client.get.
Note. These templates should have "[year]" and "[fullname]" variables to substitute. Except for licenses that do not, like the GPL which attributes copyrights to the FSF.
val license :
?var_years:string ->
?var_holder:string ->
years:string ->
holder:string ->
string ->
string * string listlicense text ~years ~holder generates a license from text in which it substitutes the var_years (defaults to "[year]") by years and var_holder (defaults to "[fullname]") by holder. The tupled list has warning messages for variables that could not be subsituted.
The defaults of var_years and var_holder match those needed by download_license_template do not rely on them otherwise.
README files
The type for README generators.
find_readme_generator file is a README generator for a file file (ignored for now).
Source files
get_src_license is like get_license except if example is true it defaults to "CC0-1.0" (TODO define a key for that).
The type for supported source language files.
pp_lang is a formatter for source language identifiers.
lang_of_id s is a language frmo the given identifier.
lang_of_file_ext tries to guess a language from the given file extension.
The type for source generators.