Configuration
Configuration parameters: [~]
docs_folder
- a path to a folder which will contain all generated documents.
NOTE be careful, all files in the
docs_folder
will be replaced by documentation files. [~]
-
project_path
- an entry point for the parser [~] -
files_patterns
- unix style pathname patterns for matching files which will be parsed. [~] -
repositories
- you can specify a repository list by setting to parse and generate documentation from all repositories from the list. It can be useful if you have many repositories.
For example a microservices architecture:
flowchart TD; A[Documentaion repo] --> B[A repo of Mecroservice 1]; A --> C[A repo of Mecroservice 2]; A --> D[A repo of Mecroservice 3];
-
repository_host
- an http url which will be used for creating a link to a file in a repository. For example, if you want to add links to your files for each section you can pass a value likehttps://github.com/user_name/project_name/blob/master
. It will be used for creating an url like thishttps://github.com/user_name/project_name/blob/master/path/to/your/file.txt
. [~] -
comment_start_string
- a string which marks the start of a comments block. Example: /** -
comment_prefix
- a comment line prefix. Example: * -
comment_end_string
- a string which marks the end of a comments block. Example: */ [~]
mdbook
- if true generates documentation in format of mdBook.
book_name
- a name of the result book.
book_build_dir
- a directory that contains the build result.
[~]
plugins_dir
- path to the plugins directory.
[~]
Fundoc will read all the configuration parameters from the fundoc.json
config file
which should be placed into the working directory of the programm's process (generally, it's a root of a
project)
[~]
You can disable parsing for a part of your file or a whole file by adding this comment: fundoc-disable
.
If you wan't to turn fundoc on few lines below just add this comment: fundoc-enable
.
In case when you don't write the enable-comment all text from disable comment until the end of the file will be ignored [~]
Plugins
You can create a plugin for Fundoc to convert any text block of the following code in documentation:
{{ #your-plugin-name any text here }}
This insertion can be multiline as well:
{{ #your-plugin-name
any text here
}}
To create a plugin for parsing these blocks, you should add a file called your-plugin-name.html.lua
into the plugins folder. By default, it's ./plugins
, but it's possible to change it in the config file.
Then you should add the following strings into the book.toml
file:
[preprocessor.your-plugin-name]
command = "fundoc -e"
The -e
artument runs Fundoc in mdBook extension mode.
And in your your-plugin-name.html.lua, you should implement text transformation like this:
function transform(text)
result = 'transformted text'
end
Fundoc calls the transform
function and passes the parsed text from the marked text block. You can transform it in any way you want.
[~]
[note] mdBook runs Fundoc twice. The first time fundoc should exit with 0 code. The second time Fundoc transforms the text. [~]
Syntax
@Article <Article name>
is for marking documentation sections to tell in which article this section should
be merged. You can use markdown
syntax in documentation sections.
Example:
/** * @Article How it works * * # Title of the article * * Some text */ fn main() {}
@FileArticle
allows you to mark a whole file is a source of documentation for a specified
article.
Example:
/** * @FileArticle How it works */ /** * Documentation for `main` */ fn main() {} /** * Documentation for `parse_files` */ fn parse_files() {}
In that case all comments from a file will be parsed in the same way if they were marked with
@Article How it works
If you want to exclude some comment from parsing you need to use @Ignore
attribute in that
section.
Example:
/** * @FileArticle How it works */ /** * Documentation for `main` */ fn main() {} /** * @Ignore * This comment will be ignored. */ fn parse_files() {}
@CodeBlockStart <Programming Language>
and @CodeBlockEnd
allow to include code from a current file as an
example.
Example:
#![allow(unused)] fn main() { /** * @Article Usage examples * Here you can see a function call: * @CodeBlockStart rust */ calc_size(item) /** * @CodeBlockEnd */ }
@Ignore
is for ignoring a marked documentation section.
[~]