Skip to content

Commit 88fbf59

Browse files
author
Chris White
committed
Updated documentation
1 parent 0e81c24 commit 88fbf59

File tree

3 files changed

+57
-25
lines changed

3 files changed

+57
-25
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for Text-PerlPP
22
(Note: GH = GitHub issue; # = RT issue)
33

4+
0.500.3 2018/05/28
5+
Fixes to tests; updated documentation
6+
47
0.500.2 2018/05/27
58
Fixes to installation package
69

README

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ README.md.
1616

1717
REQUIRES
1818

19-
Perl 5.10+ and Getopt::Long 2.50. There is a fatpacked version that
19+
Perl 5.10.1+ and Getopt::Long 2.50. There is a fatpacked version that
2020
already includes Getopt::Long in the GitHub releases archive:
2121
https://github.com/interpreters/perlpp/releases
2222

@@ -45,13 +45,46 @@ Yet another alternative way of installing
4545
- Copy lib/Text/PerlPP.pm to a directory in your @INC
4646
- Copy bin/perlpp to a directory in your PATH.
4747

48+
DEVELOPING
49+
50+
We welcome contributions through the normal GitHub pull-request (PR) workflow.
51+
The build system is straight ExtUtils::MakeMaker.
52+
53+
Before developing, run
54+
55+
perl Makefile.PL
56+
cpanm --installdeps . # if you have cpanminus installed
57+
58+
Then, to test your code directly from the lib/ directory, run
59+
60+
make testhere
61+
62+
Before submitting a PR, please test with the normal
63+
64+
make ; make test
65+
66+
sequence, as well as with
67+
68+
make testhere
69+
make testpacked
70+
71+
That last one tests the packed version made by pack.PL in blib/perlpp.
72+
We test on p5p Perl 5.10.1 (cygwin x86) and 5.26.1 (cygwin x64),
73+
and cperl 5.26.2c (cygwin x64).
74+
4875
SUPPORT AND DOCUMENTATION
4976

5077
After installing, you can find documentation for this module with the
5178
perldoc command.
5279

80+
perldoc perlpp
81+
82+
describes syntax and invocation, while
83+
5384
perldoc Text::PerlPP
5485

86+
describes using perlpp within another program.
87+
5588
You can also look for information at:
5689

5790
GitHub (report bugs here)

README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PerlPP: Perl preprocessor
44
Translates **Text+Perl** to **Text**.
55
It can be used for any kind of text templating, e.g. code generation.
66
No external modules are required, just a single file.
7-
Requires Perl 5.10+.
7+
Requires Perl 5.10.1+.
88

99
PerlPP runs in two passes: it generates a Perl script from your input, and then
1010
it runs the generated script. If you see `error at (eval ##)`
@@ -58,11 +58,11 @@ Perl code is included between `<?` and `?>` tags.
5858
There are several modes, indicated by the character after the `<?`:
5959

6060
<? code mode: Perl code is between the tags.
61-
<?= echo mode: prints a Perl expression
62-
<?: internal-command mode: executed by PerlPP itself (see below)
61+
<?= echo mode: prints a Perl expression.
62+
<?: internal-command mode: executed by PerlPP itself.
6363
<?/ code mode, beginning with printing a line break.
6464
<?# comment mode: everything in <?# ... ?> is ignored.
65-
<?! external mode: everything in <?! ... ?> is run as an external command
65+
<?! external mode: everything in <?! ... ?> is run as an external command.
6666

6767
The code mode is started by `<?` followed by any number of whitespaces
6868
or line breaks.
@@ -82,11 +82,11 @@ The Generated Script
8282

8383
The generated script:
8484

85-
- is in its own package, named based on the input filename
86-
- `use`s `5.010`, `strict`, and `warnings`
85+
- is in its own package, named based on the input filename and a unique number
86+
- `use`s `5.010001`, `strict`, and `warnings`
8787
- provides constants `true` (=`!!1`) and `false` (=`!!0`) (with `use constant`)
88-
- Declares `my %D` and initializes `%D` based on any **-D** options you provide
89-
- Declares `my %S` and initializes `%S` based on any **-s** options you provide
88+
- declares `my %D` and initializes `%D` based on any **-D** options you provide
89+
- declares `my %S` and initializes `%S` based on any **-s** options you provide
9090

9191
Other than that, everything in the script comes from your input file(s).
9292
Use the **-E** option to see the generated script.
@@ -159,7 +159,7 @@ So `<?/ ... ?>` is effectively a shorthand for `<? print "\n"; ... ?>`.
159159

160160
The example
161161

162-
<?!echo Howdy!?>
162+
<?! echo Howdy! ?>
163163

164164
produces the output
165165

@@ -203,18 +203,21 @@ In this case words like `fooSomeWord` will become `barSomeWord`.
203203

204204
will run `some_perl_code;` at the time of script generation. Whatever output
205205
the perl code produces will be included verbatim in the script output.
206+
Within `some_perl_code`, the current PerlPP instance is available as `$PSelf`.
207+
206208
This can be used to dynamically select which files you want to include,
207-
using the provided `Include()` function. For example:
209+
using the provided `Include()` method. For example:
208210

209-
<?:macro my $fn="some_name"; Include $fn; ?>
211+
<?:macro my $fn="some_name"; $PSelf->Include($fn); ?>
210212

211213
has the same effect as
212214

213215
<?:include some_name ?>
214216

215-
but `$fn` can be determined programmatically. Note that it is not currently
216-
possible to select the filename to `Include` based on defines set with **-D**,
217-
since those do not take effect until the script has been generated.
217+
but `$fn` can be determined programmatically. Note that defines set with
218+
**-D** or **-s** do not take effect effect until after the script has been
219+
generated, which is after the macro code runs. However, those are available
220+
as hashes `$PSelf->{Defs}` and `$PSelf->{Sets}` in macro code.
218221

219222
Capturing
220223
---------
@@ -298,15 +301,16 @@ Tests with `<?:if NAME ... ?>` and `<?:elsif NAME ... ?>` have two restrictions:
298301

299302
For example, `<?:if FOO eq "something" ?>` (note the whitespace before `?>`!)
300303
will work fine. However, if you want to test `(FOO+1)*3`, you will need
301-
to use the full Perl code.
304+
to use the full Perl code `<? if( (FOO+1)*3 == 42 ) { ... } ?>` instead of
305+
`<?:if ?>` and `<?:endif?>`.
302306

303307
Other Features
304308
--------------
305309

306310
### Custom Preprocessors
307311

308312
It's possible to create your own pre/post-processors in a `<?:macro ?>` block
309-
using `PerlPP::AddPreprocessor` and `PerlPP::AddPostprocessor`.
313+
using `$PSelf->AddPreprocessor` and `$PSelf->AddPostprocessor`.
310314
This feature is used in [BigBenBox](https://github.com/d-ash/BigBenBox) for
311315
generating code in the C programming language.
312316

@@ -329,14 +333,6 @@ and create corresponding *~/.vim/after/syntax/FILETYPE.vim*
329333

330334
FILETYPE can be determined with `:set ft?`
331335

332-
## Developing PerlPP
333-
334-
Perlpp should run on any Perl v5.10+. However, it does require `Getopt::Long`
335-
v2.50 or higher, so you might have to grab that from CPAN.
336-
To run the tests, you also need to grab `IPC::Run3`.
337-
338-
The `Makefile` just runs the tests in `t/`; there is no build step.
339-
340336
## Copyright
341337

342338
Distributed under the MIT license --- see

0 commit comments

Comments
 (0)