<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">[![Actions Status](https://github.com/darviarush/perl-liveman/actions/workflows/test.yml/badge.svg)](https://github.com/darviarush/perl-liveman/actions)
# NAME

Liveman - markdown compiller to test and pod.

# VERSION

1.0

# SYNOPSIS

File lib/Example.md:
```markdown
Twice two:
\```perl
2*2  # -&gt; 2+2
\```
```

Test:
```perl
use Liveman;

my $liveman = Liveman-&gt;new(prove =&gt; 1);

# compile lib/Example.md file to t/example.t and added pod to lib/Example.pm
$liveman-&gt;transform("lib/Example.md");

$liveman-&gt;{count}   # =&gt; 1
-f "t/example.t"    # =&gt; 1
-f "lib/Example.pm" # =&gt; 1

# compile all lib/**.md files with a modification time longer than their corresponding test files (t/**.t)
$liveman-&gt;transforms;
$liveman-&gt;{count}   # =&gt; 0

# compile without check modification time
Liveman-&gt;new(compile_force =&gt; 1)-&gt;transforms-&gt;{count} # =&gt; 1

# start tests with yath
my $yath_return_code = $liveman-&gt;tests-&gt;{exit_code};

$yath_return_code           # =&gt; 0
-f "cover_db/coverage.html" # =&gt; 1

# limit liveman to these files for operations transforms and tests (without cover)
my $liveman2 = Liveman-&gt;new(files =&gt; [], force_compile =&gt; 1);
```

# DESCRIPION

The problem with modern projects is that the documentation is disconnected from testing.
This means that the examples in the documentation may not work, and the documentation itself may lag behind the code.

Liveman compile `lib/**`.md files to `t/**.t` files
and it added pod-documentation to section `__END__` to `lib/**.pm` files.

Use `liveman` command for compile the documentation to the tests in catalog of your project and starts the tests:

    liveman

Run it with coverage.

Option `-o` open coverage in browser (coverage file: `cover_db/coverage.html`).

Liveman replace `our $VERSION = "...";` in `lib/**.pm` from `lib/**.md` if it exists in pm and in md.

If exists file **minil.toml**, then Liveman read `name` from it, and copy file with this name and extension `.md` to README.md.

## TYPES OF TESTS

Section codes `noname` or `perl` writes as code to `t/**.t`-file. And comment with arrow translates on test from module `Test::More`.

The test name set as the code-line.

### `is`

Compare two expressions for equivalence:

```perl
"hi!" # -&gt; "hi" . "!"
"hi!" # 竊� "hi" . "!"
```

### `is_deeply`

Compare two expressions for structures:

```perl
"hi!" # --&gt; "hi" . "!"
"hi!" # 筺ｶ "hi" . "!"
```

### `is` with extrapolate-string

Compare expression with extrapolate-string:

```perl
my $exclamation = "!";
"hi!2" # =&gt; hi${exclamation}2
"hi!2" # 竍� hi${exclamation}2
```

### `is` with nonextrapolate-string

Compare expression with nonextrapolate-string:

```perl
'hi${exclamation}3' # \&gt; hi${exclamation}3
'hi${exclamation}3' # 竊ｦ hi${exclamation}3
```

### `like`

It check a regular expression included in the expression:

```perl
'abbc' # ~&gt; b+
'abc'  # 竊ｬ b+
```

### `unlike`

It check a regular expression excluded in the expression:

```perl
'ac' # &lt;~ b+
'ac' # 竊ｫ b+
```

## EMBEDDING FILES

Each test is executed in a temporary directory, which is erased and created when the test is run.

This directory format is /tmp/.liveman/*project*/*path-to-test*/.

Code section in md-file prefixed line **File `path`:** write to file in rintime testing.

Code section in md-file prefixed line **File `path` is:** will be compared with the file by the method `Test::More::is`.

File experiment/test.txt:
```text
hi!
```

File experiment/test.txt is:
```text
hi!
```

**Attention!** An empty string between the prefix and the code is not allowed!

Prefixes maybe on russan: `ﾐ､ﾐｰﾐｹﾐｻ path:` and `ﾐ､ﾐｰﾐｹﾐｻ path ﾑ紹ｲﾐｻﾑ紹ｵﾑび��:`.

# METHODS

## new (%param)

Constructor. Has arguments:

1. `files` (array_ref) 窶� list of md-files for methods `transforms` and `tests`.
1. `open` (boolean) 窶� open coverage in browser. If is **opera** browser 窶� open in it. Else 窶� open via `xdg-open`.
1. `force_compile` (boolean) 窶� do not check the md-files modification time.
1. `options` 窶� add options in command line to yath or prove.
1. `prove` 窶� use prove, but use'nt yath.

## test_path ($md_path)

Get the path to the `t/**.t`-file from the path to the `lib/**.md`-file:

```perl
Liveman-&gt;new-&gt;test_path("lib/PathFix/RestFix.md") # =&gt; t/path-fix/rest-fix.t
```

## transform ($md_path, [$test_path])

Compile `lib/**.md`-file to `t/**.t`-file.

And method `transform` replace the **pod**-documentation in section `__END__` in `lib/**.pm`-file. And create `lib/**.pm`-file if it not exists.

File lib/Example.pm is:
```perl
package Example;

1;

__END__

=encoding utf-8

Twice two:

	2*2  # -&gt; 2+2

```

File `lib/Example.pm` was created from file `lib/Example.md` described in section `SINOPSIS` in this document.

## transforms ()

Compile `lib/**.md`-files to `t/**.t`-files.

All if `$self-&gt;{files}` is empty, or `$self-&gt;{files}`.

## tests ()

Tests `t/**.t`-files.

All if `$self-&gt;{files}` is empty, or `$self-&gt;{files}` only.

## mkmd ($md)

It make md-file.

## appends ()

Append to `lib/**.md` from `lib/**.pm` subroutines and features.

## append ($path)

Append subroutines and features from the module with `$path` into its documentation in the its sections.

File lib/Alt/The/Plan.pm:
```perl
package Alt::The::Plan;

sub planner {
	my ($self) = @_;
}

# This is first!
sub miting {
	my ($self, $meet, $man, $woman) = @_;
}

sub _exquise_me {
	my ($self, $meet, $man, $woman) = @_;
}

1;
```

```perl
-e "lib/Alt/The/Plan.md" # -&gt; undef

# Set the mocks:
*Liveman::_git_user_name = sub {'Yaroslav O. Kosmina'};
*Liveman::_git_user_email = sub {'dart@cpan.org'};
*Liveman::_year = sub {2023};
*Liveman::_license = sub {"Perl5"};
*Liveman::_land = sub {"Rusland"};

my $liveman = Liveman-&gt;new-&gt;append("lib/Alt/The/Plan.pm");
$liveman-&gt;{count}	# -&gt; 1
$liveman-&gt;{added}	# -&gt; 2

-e "lib/Alt/The/Plan.md" # -&gt; 1

# And again:
$liveman = Liveman-&gt;new-&gt;append("lib/Alt/The/Plan.pm");
$liveman-&gt;{count}	# -&gt; 1
$liveman-&gt;{added}	# -&gt; 0
```

File lib/Alt/The/Plan.md is:
```markdown
# NAME

Alt::The::Plan - 

# SYNOPSIS

\```perl
use Alt::The::Plan;

my $alt_the_plan = Alt::The::Plan-&gt;new;
\```

# DESCRIPION

.

# SUBROUTINES

## miting ($meet, $man, $woman)

This is first!

\```perl
my $alt_the_plan = Alt::The::Plan-&gt;new;
$alt_the_plan-&gt;miting($meet, $man, $woman)  # -&gt; .3
\```

## planner ()

.

\```perl
my $alt_the_plan = Alt::The::Plan-&gt;new;
$alt_the_plan-&gt;planner  # -&gt; .3
\```

# INSTALL

For install this module in your system run next [command](https://metacpan.org/pod/App::cpm):

\```sh
sudo cpm install -gvv Alt::The::Plan
\```

# AUTHOR

Yaroslav O. Kosmina [dart@cpan.org](mailto:dart@cpan.org)

# LICENSE

笞� **Perl5**

# COPYRIGHT

The Alt::The::Plan module is copyright ﾂｩ 2023 Yaroslav O. Kosmina. Rusland. All rights reserved.
```

# INSTALL

Add to **cpanfile** in your project:

```cpanfile
on 'test' =&gt; sub {
	requires 'Liveman', 
		git =&gt; 'https://github.com/darviarush/perl-liveman.git',
		ref =&gt; 'master',
	;
};
```

And run command:

```sh
$ sudo cpm install -gvv
```

# AUTHOR

Yaroslav O. Kosmina [dart@cpan.org](mailto:dart@cpan.org)

# LICENSE

笞� **GPLv3**

# COPYRIGHT

The Alt::The::Plan module is copyright ﾂｩ 2023 Yaroslav O. Kosmina. Rusland. All rights reserved.
</pre></body></html>