Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] move doc to main website and apply simple pre-commit hooks #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
skip = .git,*.pdf,*.svg
ignore-words-list = ans
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-ast
- id: check-added-large-files
- id: pretty-format-json
- id: check-case-conflict


- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '4', --sequence, '4', --offset, '0']
75 changes: 32 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# vim ft=yaml
# travis-ci.org definition for MOxUnit build (based on CoSMoMVPA,
# which is based on PyMVPA, which is based on nipype configuration,
# which is based on PyMVPA, which is based on nipype configuration,
# which in turn was based on nipy)
#
# We pretend to be java because we need GNU Octave which is not
Expand All @@ -10,54 +11,42 @@ language: java
dist: trusty
sudo: required
cache:
- apt
- apt
env:
global:
- OCTAVE=octave
matrix:
- WITH_COVERAGE=
- WITH_COVERAGE=true
global:
- OCTAVE=octave
matrix:
- WITH_COVERAGE=
- WITH_COVERAGE=true
before_install:
# to prevent IPv6 being used for APT
- sudo bash -c "echo 'Acquire::ForceIPv4 \"true\";' > /etc/apt/apt.conf.d/99force-ipv4"
- travis_retry sudo apt-get -y -qq update
- travis_retry sudo apt-get install -y -qq software-properties-common python-software-properties
- travis_retry sudo apt-add-repository -y ppa:octave/stable
- travis_retry sudo apt-get -y -qq update
- sudo bash -c "echo 'Acquire::ForceIPv4 \"true\";' > /etc/apt/apt.conf.d/99force-ipv4"
- travis_retry sudo apt-get -y -qq update
- travis_retry sudo apt-get install -y -qq software-properties-common python-software-properties
- travis_retry sudo apt-add-repository -y ppa:octave/stable
- travis_retry sudo apt-get -y -qq update
# get Octave 4,0
- travis_retry sudo apt-get -y -qq install octave liboctave-dev
- travis_retry sudo apt-get -y -qq install octave liboctave-dev
# install MOxUnit
- cd ..
- rm -rf MOxUnit
- git clone https://github.com/MOxUnit/MOxUnit.git
- make -C MOxUnit install
- cd ..
- rm -rf MOxUnit
- git clone https://github.com/MOxUnit/MOxUnit.git
- make -C MOxUnit install
# install MOcov
- rm -rf MOcov
- git clone https://github.com/MOcov/MOcov.git
- make -C MOcov install
# cd back to original directory
- cd MOdox
- rm -rf MOcov
- git clone https://github.com/MOcov/MOcov.git
- make -C MOcov install
# cd back to original directory
- cd MOdox
# show .octaverc
- cat ~/.octaverc
- cat ~/.octaverc

script:
- if [[ "$WITH_COVERAGE" == "true" ]]; then
TEST_ARGS=WITH_COVERAGE=true;
COVER_ARGS=COVER=`pwd`/MOdox;

if [[ "$SHIPPABLE" == "true" ]]; then
OUTPUT_ARGS=COVER_XML_FILE=${SHIPPABLE_BUILD_DIR}/shippable/codecoverage/coverage.xml;
AFTER_SCRIPT="find ${SHIPPABLE_BUILD_DIR}/shippable/;cat ${SHIPPABLE_BUILD_DIR}/shippable/codecoverage/coverage.xml;which reports";
elif [[ "$TRAVIS" == "true" ]]; then
OUTPUT_ARGS=COVER_JSON_FILE=`pwd`/coveralls.json;
AFTER_SCRIPT="curl --verbose -F json_file=@`pwd`/coveralls.json https://coveralls.io/api/v1/jobs";
fi;
elif [[ "$SHIPPABLE" == "true" ]]; then
RESULT_ARGS=JUNIT_XML_FILE=${SHIPPABLE_BUILD_DIR}/shippable/testresults/test_results.xml;
fi
- echo Test arguments $TEST_ARGS $COVER_ARGS $OUTPUT_ARGS $RESULT_ARGS
- make test $TEST_ARGS $COVER_ARGS $OUTPUT_ARGS $RESULT_ARGS
- eval $AFTER_SCRIPT



- "if [[ \"$WITH_COVERAGE\" == \"true\" ]]; then TEST_ARGS=WITH_COVERAGE=true; COVER_ARGS=COVER=`pwd`/MOdox;\nif [[ \"$SHIPPABLE\" == \"true\" ]];\
\ then OUTPUT_ARGS=COVER_XML_FILE=${SHIPPABLE_BUILD_DIR}/shippable/codecoverage/coverage.xml; AFTER_SCRIPT=\"find ${SHIPPABLE_BUILD_DIR}/shippable/;cat\
\ ${SHIPPABLE_BUILD_DIR}/shippable/codecoverage/coverage.xml;which reports\"; elif [[ \"$TRAVIS\" == \"true\" ]]; then OUTPUT_ARGS=COVER_JSON_FILE=`pwd`/coveralls.json;\
\ AFTER_SCRIPT=\"curl --verbose -F json_file=@`pwd`/coveralls.json https://coveralls.io/api/v1/jobs\"; fi; elif [[ \"$SHIPPABLE\" == \"true\" ]];\
\ then RESULT_ARGS=JUNIT_XML_FILE=${SHIPPABLE_BUILD_DIR}/shippable/testresults/test_results.xml; fi"
- echo Test arguments $TEST_ARGS $COVER_ARGS $OUTPUT_ARGS $RESULT_ARGS
- make test $TEST_ARGS $COVER_ARGS $OUTPUT_ARGS $RESULT_ARGS
- eval $AFTER_SCRIPT
27 changes: 27 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# schema: https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md

cff-version: 1.2.0

title: MOdox

abstract: MOdox is documentation test ("doctest") framework for Matlab and GNU Octave.

version: 0.1.0

license: MIT

repository-code: https://github.com/MOxUnit/MOdox.git

message: If you use this software, please cite it as below.

keywords:
- testing-framework
- MATLAB
- octave

authors:
- given-names: Nikolaas N.
family-names: Oosterhof
email: n.oosterhof@gmail.com
- given-names: Oliver
family-names: Heimlich
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2015-2023 Nikolaas N. Oosterhof

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion MOdox/@MOdoxDocTestParser/MOdoxDocTestParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
% Instaniate MOdoxDocTestParser object

s=struct();
obj=class(s,'MOdoxDocTestParser');
obj=class(s,'MOdoxDocTestParser');
3 changes: 1 addition & 2 deletions MOdox/@MOdoxDocTestParser/getDocTestLines.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% with indentation removed. If no documentation
% is found, then the output is an empty cell
% array.
% If a parsing error occured, then this is a
% If a parsing error occurred, then this is a
% string with the error message.
% doctest_idxs the indices of the lines with doctests, i.e.
% lines{doctest_idxs}==doctest_lines.
Expand Down Expand Up @@ -230,4 +230,3 @@ function check_inputs(obj,lines)
if ~(iscell(lines) && all(cellfun(empty_or_string,lines)))
error('Second input must be cell string');
end

2 changes: 0 additions & 2 deletions MOdox/@MOdoxDocTestParser/getHelpLines.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@
cleaner=onCleanup(@()fclose(fid));
lines_vec=fread(fid,'char=>char')';
lines=regexp(lines_vec,sprintf('\n'),'split');


2 changes: 1 addition & 1 deletion MOdox/@MOdoxDocTestParser/getOutputPrefix.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
% s string that indicates that line contains
% expected output

s='%||';
s='%||';
8 changes: 1 addition & 7 deletions MOdox/@MOdoxDocTestParser/parseLines.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[doc_lines,doc_idxs]=getDocTestLines(obj,all_lines);

if ischar(doc_lines)
% unparseable expression
% unparsable expression
reason=doc_lines;
line_number=max([1,doc_idxs(find(doc_idxs,1))]);
location=MOdoxMFileLocation(mfile_name,line_number);
Expand Down Expand Up @@ -140,9 +140,3 @@
escaped_prefix=regexptranslate('escape',prefix);

pat=['^\s*' escaped_prefix '(.*)$'];






1 change: 0 additions & 1 deletion MOdox/@MOdoxExpression/MOdoxExpression.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

s=struct();
obj=class(s,'MOdoxExpression');

2 changes: 1 addition & 1 deletion MOdox/@MOdoxMFileLocation/disp.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function disp(obj)
% display the object

fprintf('%s\n',str(obj));
fprintf('%s\n',str(obj));
2 changes: 1 addition & 1 deletion MOdox/@MOdoxMFileLocation/getFilename.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function filename=getFilename(obj)
% return filename

filename=obj.filename;
filename=obj.filename;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxMFileLocation/getLineNumber.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function line_number=getLineNumber(obj)
% return line number

line_number=obj.line_number;
line_number=obj.line_number;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxMFileLocation/str.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function s=str(obj)
% return string representation number

s=sprintf('%s: %d',getFilename(obj),getLineNumber(obj));
s=sprintf('%s: %d',getFilename(obj),getLineNumber(obj));
1 change: 0 additions & 1 deletion MOdox/@MOdoxSeparatorExpression/MOdoxSeparatorExpression.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

s=struct();
obj=class(s,'MOdoxSeparatorExpression',MOdoxExpression());

2 changes: 1 addition & 1 deletion MOdox/@MOdoxSeparatorExpression/isEvaluable.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tf=isEvaluable(obj)
% Returns true

tf=false;
tf=false;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxSeparatorExpression/isValid.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tf=isValid(obj)
% Returns true

tf=true;
tf=true;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxSeparatorExpression/str.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function s=str(obj)
% Return string representation of expression
s=repmat('-',1,20);
s=repmat('-',1,20);
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCase/getExpressions.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
% Output:
% expr cell with MOdoxExpression instances

expr=obj.expressions;
expr=obj.expressions;
6 changes: 1 addition & 5 deletions MOdox/@MOdoxTestCase/run.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
DXD__expression=DXD__expressions{DXD__i};

if ~isValid(DXD__expression)
% unparseable expression
% unparsable expression
DXD__reason=getReason(DXD__expression);
DXD__outcome_args=DXD__build_error_struct(DXD__reason,...
DXD__expression);
Expand Down Expand Up @@ -187,7 +187,3 @@

function line=remove_ans_eq(line)
line=regexprep(line,'^\s*ans\s*=','');




2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/MOdoxTestCaseExpression.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% location MOdoxMFileLocation instance
% lines cellstring with matlab code
% output_prefix (optional) string prefix for output
% output cellstring with expectd output
% output cellstring with expected output


check_inputs(location,code,output_prefix,output)
Expand Down
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/disp.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function disp(obj)
s=str(obj);
fprintf('%s:\n%s',class(obj),s);
fprintf('%s:\n%s',class(obj),s);
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/getCode.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function code=getCode(obj)
% Return code (without prefix)

code=obj.code;
code=obj.code;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/getLocation.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function location=getLocation(obj)
% Return location

location=obj.location;
location=obj.location;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/getOutput.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function code=getOutput(obj)
% Return code (without prefix)

code=obj.output;
code=obj.output;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/getOutputPrefix.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function prefix=getOutputPrefix(obj)
% Return prefix

prefix=obj.output_prefix;
prefix=obj.output_prefix;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/isEvaluable.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tf=isEvaluable(obj)
% Returns true

tf=true;
tf=true;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxTestCaseExpression/isValid.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tf=isValid(obj)
% Returns true

tf=true;
tf=true;
2 changes: 0 additions & 2 deletions MOdox/@MOdoxTestSuite/MOdoxTestSuite.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@

s=struct();
obj=class(s,class_name,MOxUnitTestSuite(name));


1 change: 0 additions & 1 deletion MOdox/@MOdoxTestSuite/addFromFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@
end
end
end

2 changes: 1 addition & 1 deletion MOdox/@MOdoxUnparseableExpression/getLocation.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function location=getLocation(obj)
% Return location

location=obj.location;
location=obj.location;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxUnparseableExpression/getReason.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function reason=getReason(obj)
% return parse error reason

reason=obj.reason;
reason=obj.reason;
2 changes: 1 addition & 1 deletion MOdox/@MOdoxUnparseableExpression/isEvaluable.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tf=isEvaluable(obj)
% Returns true

tf=true;
tf=true;
Loading