package b0

  1. Overview
  2. Docs
Software construction and deployment kit

Install

dune-project
 Dependency

Authors

Maintainers

Sources

b0-0.0.6.tbz
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

Sourceval find_project_meta : unit -> B0_meta.t option

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).

Sourceval get_project_meta : unit -> B0_meta.t

get_project_meta () is like find_project_meta but defaults to B0_meta.empty.

Sourceval default_root_markers : string list

default_root_marker filenames that could denote the root of a project's source tree.

Sourceval find_project_name : ?root_markers:string list -> cwd:B0_std.Fpath.t -> unit -> (string option, string) result

find_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

Sourcetype changes = unit -> string

The type for changes generators.

Sourceval find_changes_generator : B0_std.Fpath.t -> (changes, string) result

find_changes_generator f is a changes generator for a file file (ignored for now).

LICENSE files

Sourceval find_project_license : B0_meta.t -> B0_meta.spdxid option

find_project_license m looks the first B0_meta.licenses in meta.

Sourceval get_license : B0_meta.t -> B0_meta.spdxid option -> B0_meta.spdxid

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).

Sourceval download_license_template : ?httpc:B0_http.Http_client.t -> strip_meta:bool -> B0_meta.spdxid -> (string, string) result

download_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.

Sourceval license : ?var_years:string -> ?var_holder:string -> years:string -> holder:string -> string -> string * string list

license 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

Sourcetype readme = project_name:string -> synopsis:string option -> B0_meta.t -> string

The type for README generators.

Sourceval find_readme_generator : B0_std.Fpath.t -> (readme, string) result

find_readme_generator file is a README generator for a file file (ignored for now).

Source files

Sourceval get_src_license : B0_meta.t -> example:bool -> B0_meta.spdxid option -> B0_meta.spdxid

get_src_license is like get_license except if example is true it defaults to "CC0-1.0" (TODO define a key for that).

Sourcetype lang = [
  1. | `C
  2. | `Css
  3. | `Haskell
  4. | `Html
  5. | `Javascript
  6. | `Java
  7. | `Ocaml
  8. | `Racket
  9. | `Rust
  10. | `Sh
]

The type for supported source language files.

Sourceval pp_lang_id : lang B0_std.Fmt.t

pp_lang is a formatter for source language identifiers.

Sourceval lang_to_id : lang -> string

lang_to_id lang is a lowercased identifier for lang.

Sourceval lang_of_id : string -> (lang, string) result

lang_of_id s is a language frmo the given identifier.

Sourceval lang_of_file_ext : B0_std.Fpath.ext -> lang option

lang_of_file_ext tries to guess a language from the given file extension.

Sourcetype src = years:string -> holder:string -> license:B0_meta.spdxid -> string

The type for source generators.

Sourceval src_generator : lang -> src

src_generator lang is a source generator for language lang.