Skip to content

Commit 157c0ea

Browse files
authored
Update README.md
1 parent 40cb046 commit 157c0ea

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

README.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ Matlab-Templates is a collection of functions for quickly generating pre-edited
44
for specific use cases: creating new classes, new tests...
55
It is based on the 'tedit' function, originally written by Peter Bodin.
66

7-
Each function in the template has a name in the 'newXXX' format.
8-
When the function is called with the name of the item, a new file is created, and the editor opens
7+
The main functions are:
8+
9+
* **newClass**: create a new file containing a class definition template
10+
* **newTest**: create a new file containing a minimal implementation for running unit tests
11+
* **newEnum**: create a new file containing a minimal implementation for an enumeration class
12+
13+
Each function has to be called with the name of the item to create.
14+
This creates a new file (based on the item name), and opens the editor
915
with a pre-edited header and code structure.
10-
In particular, author name, copyright information, date of creation... are automatically updated.
11-
The templates can be modified by editing the 'newXXX' functions.
16+
In particular, author name, copyright information, date of creation... are automatically populated
17+
based on the templates defined in the 'newXXX' functions.
1218

19+
## Installation
1320

14-
## Main functions
21+
The library is composed of a single directory containing all the necessary functions.
22+
The installation can be performed by simply cloning (or extracting the archive),
23+
and adding the path to the library to the Matlab path list.
1524

16-
### Creating new class
25+
## Creating a new class
1726

1827
The newClass function can be used to create a new file containing a class definition.
1928

@@ -26,16 +35,10 @@ The new file contains the following code patterns:
2635
* a constructor stub
2736
* space for specific methods
2837

29-
### Creating new test
30-
31-
The newTest function can be used to create a new file containing a minimal implementation for running unit tests.
32-
33-
newTest(FUNCTIONTOTEST)
34-
3538

36-
## Class pattern example
39+
### Class pattern example
3740

38-
The following is the result of the creation of a new class called `SampleClass` , using the `newClass('SampleClass')` command:
41+
The following is the result of the creation of a new file called `SampleClass.m`, defining the class `SampleClass`, using the command `newClass('SampleClass')`:
3942

4043
classdef SampleClass < handle
4144
% One-line description here, please.
@@ -77,3 +80,36 @@ The following is the result of the creation of a new class called `SampleClass`
7780
end % end classdef
7881

7982

83+
## Creating new test
84+
85+
The newTest function can be used to create a new file containing a minimal implementation for running unit tests.
86+
87+
newTest(FUNCTIONTOTEST)
88+
89+
The following is the result of the command `newTest('foo')`:
90+
91+
function tests = test_foo
92+
% Test suite for the file foo.
93+
%
94+
% Test suite for the file foo
95+
%
96+
% Example
97+
% test_foo
98+
%
99+
% See also
100+
% foo
101+
102+
% ------
103+
% Author: David Legland
104+
105+
% Created: 2021-09-10, using Matlab 9.10.0.1684407 (R2021a) Update 3
106+
% Copyright 2021 INRAE - BIA-BIBS.
107+
108+
tests = functiontests(localfunctions);
109+
110+
function test_Simple(testCase) %#ok<*DEFNU>
111+
% Test call of function without argument.
112+
foo();
113+
value = 10;
114+
assertEqual(testCase, value, 10);
115+

0 commit comments

Comments
 (0)