Config
module
Kit::Doc::Services::Config
View Source
Configuration related logic.
The most important thing is the expected configuration format, documented in Kit::Doc::Services::Config.create_config.
Link to this section Summary ⚠️ Private APIs are currently hidden.
Link to this section Class methods 5
Configuration normalization for Kit::Doc.
opts is a hash that can contain the following keys:
:project_path- Absolute path of the project home directory.:git_project_path- Absolute path of the project git home directory. It will sometimes be different from:project_pathin a multi-project setup. This is necessary when usingall_versionstasks, that will checkout different versions of the project.:project- Project name. Autofilled from gemspec if:gemspec_nameis set.:current_version- Semver name of the current version. Example: "0.1.0". Defaults todev(this is the most common usage: previewing new documentation).:source_ref- The branch/commit/tag used for source link inference. Autogenerated if nil. If:git_project_pathis set, the current branch be used if found, last commit otherwise. Defaults tomasterotherwise.:current_version_display- Version that will be displayed. Autogenerated if nil: addvin front of:versionvalues that start with an integer. Example:version: '0.1.0'would lead toversion_display: 'v0.1.0'.:all_versions- List of version & source_ref to be used forall_versionstasks and javascriptversionNodes. Example:[{ version: 'edge', source_ref: 'master' }, { version: 'v0.0.1', source_ref: 'v0.0.1' }]If a string is given, assume it is the path to aVERSIONSfile that will be loaded.:output_dir_all_versions- Container directory for various versioned generated docs. Defaults to"#{ project_path }/docs/dist". If a relative path is provided it will be auto-expanded to an absolute path.:output_dir_current_version- Output directory for the generated docs. If a relative path is provided it will be auto-expanded to an absolute path. Auto-generated from:output_dir_all_versionsand:current_versionif nil.:documentation_url- The address of the generated documentation. Autofilled from gemspec if:gemspec_nameis set.:source_url- The address of code source. Autofilled from gemspec if:gemspec_nameis set.:url_mode- Defaults to:local. If:local,:documentation_urlis set tofile://URI scheme. Useful for browsingdevdocumentation. (TODO: apply tosource_urlalso when we find a good way to preview code locally.view-sourceURI scheme does not have syntax highligthing or line number anchors.):files_modules- List of files to generate documentation from. SeeKit::Doc::Services::Tasks::Helpers.resolve_filesfor a helper to express that list in a terser way.:groups_for_modules- See the "Groups" section:files_extras- List of Markdown files to add to the documentation. SeeKit::Doc::Services::Tasks::Helpers.resolve_filesfor a helper to express that list in a terser way.:groups_for_extras- See the "Groups" section:extras_section_name- String that defines the section title of the additional Markdown pages. Defaults to "Guides".:logo- Path to the image logo of the project.:authors- List of authors for the generated docs. Autofilled from gemspec if:gemspec_nameis set.:markdown_variables- Hash of values available in Markdown pre-processing. SeeKit::Doc::Services::MarkdownPreprocessor.:assets- List of paths to files or directories that will be copied as is to the "assets" directory in the output path.:main_redirect_url- Path to the default page for the documentation. The top levelindex.htmlfor the:current_versiondocumentation will redirect there. Defaults to "api_reference.html".
Groups
The output sidebar content can be organized in groups. This is done via the :groups_for_extras
and :groups_for_modules. For example, imagine you are storing extra guides in
your documentation which are organized per directory. In the extras section you have:
extras: [
"guides/introduction/foo.md",
"guides/introduction/bar.md",
# ...
"guides/advanced/baz.md",
"guides/advanced/bat.md",
],
You can have those grouped as follows:
groups_for_extras: {
'Introduction' => [%r{guides/introduction/.?}],
'Advanced' => [%r{guides/advanced/.?}],
},
Similar can be done for modules:
groups_for_modules: {
# The "empty" group is where modules not included in another group go.
'' => [
{
# Here we define the ones we want to hide from that category.
inclusion: %r{^(Kit|Kit::Doc|Kit::Doc::Services)$},
display: false,
},
],
'Services' => [
{
# Match on the fully qualified name.
inclusion: %r{^Kit::Doc::Services::.*},
# A callable that will receive and modify the display name of the module.
display_title: ->(name) { name.split('::')[-1] },
# A callable that will the name of the module and return a list of css classes to be applied.
# This can for instance be used to add padding.
css_classes: ->(name) do
size = name.gsub('hide', 'Kit::Doc::Services::').scan('::').size
["#{ (size > 0) ? "sidebar-pl-#{ size }" : '' }"]
end,
},
],
Generate a versioned source link for a given source_ref & path & line number.
Attempt to guess the most accurate git source_ref.
If git_project_path is set, it will attempt to find the current branch first, then the last commit.
Otherwise, defaults to master.
Load a gemspec file data.
Parse a VERSIONS file.
It contains all versions we want to generate documentation for.
Expected format
On each line:
version[:source_ref]`
version- The name of the version.source_ref- The branch/commit/tag used for source link inference. Defaults toversionif not specified.
Example
edge:master
v0.0.1
Link to this section Instance attributes 1
This Service currently acts as a singleton to reference the current config for Yard rake tasks.
This is obviously not ideal / thread safe, but it is only used for tooling, so it does not matter.
Link to this section Constants 1
A regex that match semantic versioning (semver) versions.
Note that this is a more permissive version to match semver inside strings and allow for leading v.
References:
%r{(v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)}