pasdoc/ 0000700 0001750 0001750 00000000000 13237145537 012473 5 ustar michalis michalis pasdoc/pasdoc-fpc.cfg 0000700 0001750 0001750 00000002407 13034465544 015177 0 ustar michalis michalis # -*- mode: shell-script -*- # These are FPC-specific options for compiling pasdoc. # Path options (-Fu, -Fi) are not specified here -- they are specified only # in the Makefile (to avoid duplication, of course). # # What are the reasons for maintaining this cfg file # (as opposed to dropping this cfg file and specifying all compilation options # in the Makefile) ? # # 1. This looks a little clearer than typing these options in the Makefile ? # # 2. Using #IFDEF AMIGA below. Although Amiga is not actually supported # target now. # # In the future, this file may be removed and everything will be handled # only inside the Makefile. # Syntax settings: objfpc mode, ansistrings -S2 -Sh # Io checking -Ci # Show warnings and notes -vwn #IFDEF RELEASE #ifdef AMIGA -Ct #endif # Optimize, for faster code -OG -O2 #ELSE # Range, overflow, stack checking, verify object method call validity -Cr -Co -Ct -CR # Include assertions -Sa # Generate debug info for gdb, include lineinfo -g -gl # On Mac OS X > 10.4 debug information is needed in dwarf format. # Seems that it works also in Mac OS X 10.4.11, so we just activate dwarf always. # See http://lazarus.freepascal.org/index.php?topic=10972.0 #ifdef DARWIN -gw #endif # Uncomment to check for memory leaks. #-gh #ENDIF pasdoc/README.md 0000600 0001750 0001750 00000000542 13034465544 013753 0 ustar michalis michalis # PasDoc PasDoc is a documentation tool for Pascal and Object Pascal source code. Documentation is generated from comments found in the source code or from external files. Many formatting @-tags are supported. Many output formats are supported, including HTML and LaTeX. See the documentation on http://pasdoc.sourceforge.net/ . # License GNU GPL 2. pasdoc/.gitattributes 0000600 0001750 0001750 00000000037 13034465544 015366 0 ustar michalis michalis *.inc linguist-language=Pascal pasdoc/tests/ 0000700 0001750 0001750 00000000000 13237142323 013623 5 ustar michalis michalis pasdoc/tests/run_all_tests.sh 0000755 0001750 0001750 00000002513 13237136021 017051 0 ustar michalis michalis #!/bin/bash set -eu # Run all PasDoc tests. make clean # fpcunit tests -------------------------------------------------------------- cd fpcunit/ make cd ../ # run on testcases, compare with correct output ------------------------------ ALL_OUTPUT_FORMATS='html htmlhelp latex latex2rtf simplexml' cd scripts/ ./download_correct_tests_output.sh $ALL_OUTPUT_FORMATS cd ../ for OUTPUT_FORMAT in $ALL_OUTPUT_FORMATS; do cd testcases/ ../scripts/mk_tests.sh $OUTPUT_FORMAT cd ../ diff -wur correct_output/$OUTPUT_FORMAT current_output/$OUTPUT_FORMAT done # If you detect any *valid* differences, i.e. the new version is more correct, # run this: # cd scripts/ && ./upload_correct_tests_output.sh $SOURCEFORGE_USERNAME $ALL_OUTPUT_FORMATS && cd ../ # validation ----------------------------------------------------------------- # Validate current_output/html, requires onsgmls installed # This is unfortunately not working for HTML 5 now. # scripts/validate_html.sh # Validate current_output/simplexml, requires xmllint installed scripts/validate_simplexml.sh # cache tests ---------------------------------------------------------------- cd scripts/ for OUTPUT_FORMAT in $ALL_OUTPUT_FORMATS; do ./check_cache.sh $OUTPUT_FORMAT done ./check_cache_format_independent.sh html latex ./check_cache_format_independent.sh latex2rtf htmlhelp pasdoc/tests/fpcunit/ 0000700 0001750 0001750 00000000000 13237143041 015271 5 ustar michalis michalis pasdoc/tests/fpcunit/testpasdoc_utils.pas 0000600 0001750 0001750 00000003761 13237143041 021400 0 ustar michalis michalis { Copyright 2016-2016 PasDoc developers. This file is part of "PasDoc". "PasDoc" is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. "PasDoc" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with "PasDoc"; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---------------------------------------------------------------------------- } { Test PasDoc_Utils. } unit TestPasdoc_Utils; interface uses Classes, SysUtils, FpcUnit, TestUtils, TestRegistry; type TTestPasDocUtils = class(TTestCase) published procedure TestRemoveIndentation; end; implementation uses PasDoc_Utils; procedure TTestPasDocUtils.TestRemoveIndentation; begin AssertEquals( ' ' + LineEnding + // whitespace line will be completely ignored ' foo' + LineEnding + 'bar' + LineEnding + ' xyz', RemoveIndentation( ' ' + LineEnding + // whitespace line will be completely ignored ' foo' + LineEnding + ' bar' + LineEnding + ' xyz')); AssertEquals( ' '#9' ' + LineEnding + // whitespace line will be completely ignored #9' foo' + LineEnding + 'bar' + LineEnding + ' xyz', RemoveIndentation( ' '#9' ' + LineEnding + // whitespace line will be completely ignored ' '#9#9' foo' + LineEnding + ' '#9'bar' + LineEnding + ' '#9' xyz')); AssertEquals('begin Writeln(''Hello world''); end; { This works ! }', RemoveIndentation(' begin Writeln(''Hello world''); end; { This works ! } ')); end; initialization RegisterTest(TTestPasDocUtils); end. pasdoc/tests/fpcunit/test_pasdoc.lpr 0000600 0001750 0001750 00000002362 13034465544 020337 0 ustar michalis michalis { Copyright 2016-2016 PasDoc developers. This file is part of "PasDoc". "PasDoc" is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. "PasDoc" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with "PasDoc"; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---------------------------------------------------------------------------- } { Automatic test runner. } uses SysUtils, ConsoleTestRunner, { specify TestXxx units below. } TestPasDoc_Utils, TestPasdoc_GenHtml; var Application: TTestRunner; begin Application := TTestRunner.Create(nil); try Application.Title := 'PasDoc - Test runner (using fpcunit)'; DefaultFormat := fPlain; Application.Initialize; Application.Run; finally FreeAndNil(Application) end; end. pasdoc/tests/fpcunit/testpasdoc_genhtml.pas 0000600 0001750 0001750 00000006013 13237143041 021667 0 ustar michalis michalis { Copyright 2016-2016 PasDoc developers. This file is part of "PasDoc". "PasDoc" is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. "PasDoc" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with "PasDoc"; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---------------------------------------------------------------------------- } { Test PasDoc_GenHtml. } unit TestPasdoc_GenHtml; interface uses Classes, SysUtils, FpcUnit, TestUtils, TestRegistry; type TTestPasDocGenHtml = class(TTestCase) published procedure TestFormatPascalCode; end; implementation uses PasDoc_GenHtml; type { Descendant of THTMLDocGenerator, to access here some protected methods of THTMLDocGenerator. } TMyHTMLDocGenerator = class(THTMLDocGenerator) end; procedure TTestPasDocGenHtml.TestFormatPascalCode; var Gen: TMyHTMLDocGenerator; begin Gen := TMyHTMLDocGenerator.Create(nil); try AssertEquals('
' + LineEnding + LineEnding + 'begin Writeln(''Hello world''); end; { This works ! }' + LineEnding + LineEnding + '
', Gen.FormatPascalCode('begin Writeln(''Hello world''); end; { This works ! } ')); { should work the same as before (there was a bug at some point where the lack of space right after comment was confusing the code) } AssertEquals('
' + LineEnding + LineEnding + 'begin Writeln(''Hello world''); end; { This works ! }' + LineEnding + LineEnding + '
', Gen.FormatPascalCode('begin Writeln(''Hello world''); end; { This works ! }')); AssertEquals('
' + LineEnding + LineEnding + '{ unterminated
' + LineEnding +
LineEnding +
'', Gen.FormatPascalCode('{ unterminated ')); AssertEquals('
' + LineEnding + LineEnding + '(* unterminated
' + LineEnding +
LineEnding +
'', Gen.FormatPascalCode('(* unterminated ')); AssertEquals('
' + LineEnding + LineEnding + '// unterminated
' + LineEnding +
LineEnding +
'', Gen.FormatPascalCode('// unterminated '));
finally FreeAndNil(Gen) end;
end;
initialization
RegisterTest(TTestPasDocGenHtml);
end.
pasdoc/tests/fpcunit/Makefile 0000600 0001750 0001750 00000000057 13034465544 016747 0 ustar michalis michalis .PHONY: default
default:
make -C ../../ tests
pasdoc/tests/README.md 0000600 0001750 0001750 00000027257 13237137561 015131 0 ustar michalis michalis # Tests for PasDoc
Run all the tests simply by `run_all_tests.sh`.
This runs all relevant tests described below.
It requires a Unix shell (on Windows, you should install Cygwin or MSys).
# Testcases
The subdirectory `testcases` contains
some short and difficult Pasdoc sources. Some of these are taken
from bugreports, to make sure we don't reintroduce an old bug again.
Some of these are written to test new features.
To add a new testcase,
1. first of all just add the file here
(follow the naming conventions below, usually just ok_xxx.pas).
2. add an appropriate line at the end of scripts/mk_tests.sh.
3. after you make sure it works, you may upload new
version of "correct tests", see below. Or just notify Michalis about it :)
Using these tests fully requires having some standard Unix tools
installed and available on $PATH. You need GNU `make`, bash, diff.
Also wget is used for downloading correct tests for comparison.
And tar, scp are used for uploading correct tests by developers.
Of course, you also need the `pasdoc` binary available on $PATH.
## Naming of Pascal unit files in this directory
- `ok_*`
Means that this unit should be parsed by pasdoc without any warnings.
- `warning_*`
Means that this unit should be parsed by pasdoc (i.e. some documentation
for it should be generated), but some warnings should be reported
by pasdoc.
- `error_*`
Means that pasdoc should not be able to parse this unit,
documentation for this unit shouldn't be possible to generate.
pasdoc should generate proper error message for this case.
Note that pasdoc may report errors as warnings,
e.g. "Warning[2]: Error EPasDoc: error_line_number.pas(26):
could not open include file not_existing.inc ..."
Pasdoc calls this a warning, since, after all, it can continue
it's work by simply skipping to the next unit.
But for the sake of this distinction, this is an *error*,
not merely a *warning*.
The precise difference between an error and a warning is:
"error makes impossible to generate documentation for this unit".
Units are divided into these 3 groups because:
- These groups are precisely defined, so there shouldn't be any concern
about "where this test unit belongs".
- We should be eventually able to use output messages and exit status
of pasdoc to automate testing as much as we can.
Notes:
- Please keep prefixes "ok_", "warning_", "error_" lowercase so that
e.g. the file-mask `ok_*` works as expected on case-sensitive file-systems.
Try to follow the convention
"prefix_description_of_test_lowercase_with_underscores.pas".
- Most of these units will have empty implementation.
They are not supposed to be ever compiled by anything.
- There is no requirement here that the interface of units
placed here must be correct Pascal code.
Pasdoc should be able to handle even incorrect units.
Usually it should break with some parsing error on such units,
but it doesn't have to (after all, pasdoc is not meant to
exactly reimplement some part of a compiler that carefully checks
syntax and everything), it may try to generate some docs.
But even with incorrect units, it obviously shouldn't fail with some
miserable error (like sigsegv :) or do anything that it shouldn't,
like removing some files or so.
- If you want to test unit with a special pasdoc's command-line,
you must add appropriate line at the end of ./mk_tests.sh script.
## Possible tests to be done
First of all, you can just run `run_all_tests.sh` that runs all
relevant tests described below.
- Generate output like this:
```
cd testcases/
../scripts/mk_tests.sh html
```
Tests are created in `current_output/html` subdirectory.
Some of our other scripts will use it.
You can just manually look at units'
sources and comments there to know what generated documentation should
look like (in case of `ok_*` and `warning_*` files) and what
warnings/errors should be reported (in case of `warning_*` and `error_*` files).
Of course, even briefly checking that all `ok_*` units generate no warnings,
all `warning_*` units generate some warnings (and produce some docs)
and all `error_*` units generate errors (and no docs)
is still a better test than nothing...
Note that pasdoc messages (printed on stdout) will not be shown
when you will make tests using mentioned `make ...' commands.
Instead they will be saved to files named PASDOC-OUTPUT
in appropriate subdirectories of tests output.
This way we treat messages printed by pasdoc as important part
of pasdoc's output, they are included in "correct tests output"
(see below) so comparing with "correct tests output" also checks
that pasdoc messages are correct (warnings are as they should be
and where they should be etc.)
- "Correct tests output" give an automated way to verify `current_output/html`.
We maintain on [http://pasdoc.sourceforge.net/correct_tests_output/]
something that we call "correct output of tests".
Everyone can download them simply by:
```
cd scripts/
./download_correct_tests_output.sh html
```
Then whenever you want you can compare current documentation generated
by pasdoc to downloaded "correct output" e.g. using
```
diff -ur correct_output/html/ current_output/html/
```
Note that *failure* of comparison does not necessarily mean that
current pasdoc *has* a bug, since it's possible that current output of
pasdoc is different (because e.g. we improved and changed something)
but still correct.
Also *success* of comparison does not mean that current pasdoc does
*not* have a bug, because this "current output" was just
accepted at some point by human as "correct".
So, this is unfortunately no ultimate test.
But in practice it often works great, and allows us to quickly
check that nothing is broken :) When no output changes are expected,
or the changes are very local, then looking at "diff" output is a great
and simple way to test.
If pasdoc's developer sees at any point that "current output" differs
from "correct output" and also he carefully checked that "current
output" is still correct, than he should upload his "current output"
as new "correct output" by entering scripts/ directory and executing
```
./upload_correct_tests_output.sh username html
```
See documentation inside scripts/upload_correct_tests_output.sh
for more detailed docs. Note that before uploading you should
be relatively sure that you compared against most recent version
of "correct output", to save yourself trouble of unnecessary
uploading.
Beware that script `upload_correct_tests_output.sh'
will upload everything that you will have inside subdirectory
of given format. This is painful in case of output like LaTeX,
where you can accidentally upload files like docs.pdf or docs.dvi
(that shouldn't be uploaded).
In this case you can do something like `make clean latex' before
uploading to be sure that you upload only "docs.tex" file.
- `scripts/validate_html.sh`
This is an automatic test that makes html docs for all test units
and validates them using sgml validator.
onsgmls program must be installed for this to work.
Links how to install onsgmls may be found here
[https://github.com/pasdoc/pasdoc/wiki/HtmlOutput].
- `scripts/validate_simplexml.sh`
This is an automatic test that makes simplexml docs for all test units
and validates them using xmllint.
xmllint must be installed for this to work.
We do not have any DTD, so it doesn't check that our XML files
conform to anything. But at least it checks that they are well-formed
(all open elements are closed and such).
- Cache tests:
```
cd scripts/
./check_cache.sh html
./check_cache.sh latex
```
$1 arg for this script is required and is any valid pasdoc format
(as for pasdoc's --format option).
Rest of args are just passed to pasdoc as they are.
This runs pasdoc twice using the cache,
1st time the cache directory is empty and pasdoc writes the cache,
2nd time pasdoc should read everything from the cache.
The script then checks that pasdoc's output was identical each time
(comparing them with `diff -u', so you get diff on output if something
does not match).
This somehow checks that writing the cache and reading the cache
and writing documentation basing on information obtained from the cache
(instead of from parsing units) works OK.
Everything is read/written to a temporary directory scripts/check_cache_tmp/,
that is removed at the beginning and at the end of the script.
(It's removed at the beginning, and also by `make clean`, just to
make sure that no garbage is left there, in case script failed
for whatever reason.)
So this script is mostly independent from the rest of the tests
here -- it just happens to use the same test units.
In case comparison between two outputs failed both outputs
and left in scripts/check_cache_tmp/, so developer can inspect
them closer.
- Test cache is format-independent:
```
cd scripts/
./check_cache_format_independent.sh html latex
./check_cache_format_independent.sh latex html
```
Requires two arguments, two names of pasdoc output format.
These two formats should be different for this test to be really sensible
(and better than check_cache.sh), but they can also be equal and
test should pass anyway.
This is similar to ./check_cache.sh test, but it checks
that cache format is independent of pasdoc's output format.
1st it generates output with format 1, without using any cache.
2nd it generates output with format 2, writing the cache.
3rd it generates output with format 1, this time reading the cache.
Then it checks that 1st and 3rd output are equal.
This way it checks that cache generated while doing format 2
may be reused while making format 1. So it tests that cache
format is really independent from pasdoc's chosen output format.
## Various notes
`make clean` will clean this directory.
Note that make used must be GNU make.
Under Linux this is standard, under FreeBSD this is called `gmake`,
under Win32 you can get this with e.g. FPC, MinGW or Cygwin.
scripts/ subdirectory contains some helpful things for running tests.
These should be scripts that perform some additional tests
on test units available here (like check_cache.sh),
but also some helper scripts/files for Makefile in this directory.
## Subdirectory testcases/todo/
It contains units that are known to
be incorrectly handled by pasdoc by now. "Incorrectly handled"
may mean that generated documentation is incorrect, or that pasdoc
fails with some error on correct input, but "incorrectly handled"
may also mean that pasdoc fails to write a proper warning/error
in case when input (unit's sources) is obviously wrong.
Files inside todo/ should follow exactly the same naming convention
as units in this directory (`ok_*`, `warning_*`, `error_*`).
In this case, unit's name tells what pasdoc *should* do with such unit,
even if it doesn't do it for now.
The idea is that when developer fixes a problem with some unit
in tests/todo/ directory, he can simply move this unit to tests/.
These files are in separate todo/ subdirectory, because otherwise
every time we would like to check our tests we would have to
remember "oh, such-and-such test fails but it's a known problem,
so I can ignore it". This would be troublesome,
because *usually* we will want to test whether we did not break
anything that previously worked, and we will not care that there
are still some unresolved problems in pasdoc.
---
And that's all for now.
Comments are most welcome.
pasdoc/tests/scripts/ 0000700 0001750 0001750 00000000000 13237142210 015305 5 ustar michalis michalis pasdoc/tests/scripts/validate_simplexml.sh 0000700 0001750 0001750 00000000542 13237126412 021536 0 ustar michalis michalis #!/bin/bash
set -eu
# This scripts runs xmllint to check every *.xml file in simplexml/
# subdirectory, recursively.
# It's meant to be run using `make validate_simplexml' in parent directory.
#
# See ../README for comments.
find current_output/simplexml/ -iname '*.xml' \
-exec sh -c 'echo ---- Validating {}' ';' \
-exec xmllint --noout '{}' ';'
pasdoc/tests/scripts/download_correct_tests_output.sh 0000700 0001750 0001750 00000001710 13034465544 024052 0 ustar michalis michalis #!/bin/bash
set -eu
# Always run this script with current directory set to
# directory where this script is,
# i.e. tests/scripts/ inside pasdoc sources.
#
# $1 is pasdoc's format name, like for pasdoc's --format option.
#
# This script
# - cleans ../correct_output/$1/
# - downloads [http://pasdoc.sourceforge.net/correct_tests_output/$1.tar.gz]
# - and unpacks it to ../correct_output/$1/
#
# Requisites: downloading is done using `wget'.
download_one_format ()
{
# Parse options
FORMAT="$1"
shift 1
ARCHIVE_FILENAME_NONDIR="$FORMAT".tar.gz
rm -Rf ../correct_output/"$FORMAT"/ ../correct_output/"$ARCHIVE_FILENAME_NONDIR"
mkdir -p ../correct_output/
cd ../correct_output/
echo "Downloading $ARCHIVE_FILENAME_NONDIR ..."
wget http://pasdoc.sourceforge.net/correct_tests_output/"$ARCHIVE_FILENAME_NONDIR"
echo "Unpacking $ARCHIVE_FILENAME_NONDIR ..."
tar xzf "$ARCHIVE_FILENAME_NONDIR"
}
for FORMAT; do
download_one_format "$FORMAT"
done pasdoc/tests/scripts/ssh_chmod_writeable_by_pasdoc.sh 0000700 0001750 0001750 00000001605 13034465544 023713 0 ustar michalis michalis #!/bin/bash
set -eu
# $1 is your username on sourceforge,
# $2 is directory on sourcefore (usually you will start this with
# /home/project-web/pasdoc/...).
#
# This script logs to sourceforge using given username
# (you will be asked for password unless you set up ssh keys)
# and executes
# chgrp -R pasdoc *
# chmod -R g+w *
# This means that every file in given directory is made writeable
# by pasdoc group, which means pasdoc developers.
#
# Later note: chgrp -R pasdoc is not supported on SF anymore.
# Group is always "apache", and for security I would not like to have
# files writeable by apache on a shared host.
echo 'ssh_chmod_writeable_by_pasdoc: Not changing permissions, as it is no longer possible on SourceForge.'
# SF_USERNAME="$1"
# SF_PATH="$2"
# shift 2
# ssh -l "$SF_USERNAME" shell.sourceforge.net <