Skip to content

Commit f956792

Browse files
authored
Add .gomarkdoc.yml and update docs (#173)
# Describe Request This PR introduces `.gomarkdoc.yml` which includes default configuration of gomarkdoc. This way, we can reuse the same configuration across multiple invocations such as `pre-commit.sh` and github workflow. Also, docs are updated by executing pre-commit.sh. Fixed # partially #172 # Change Type Docs.
1 parent 7168efc commit f956792

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

.gomarkdoc.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
excludeDirs: "./cmd/..."
2+
output: "{{.Dir}}/README.md"
3+
repository:
4+
url: https://github.com/cinar/indicator

helper/README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ const (
124124
)
125125
```
126126

127+
<a name="DefaultReportDateFormat"></a>
128+
129+
```go
130+
const (
131+
// DefaultReportDateFormat is the default date format used in the report.
132+
DefaultReportDateFormat = "2006-01-02"
133+
)
134+
```
135+
127136
<a name="Abs"></a>
128137
## func [Abs](<https://github.com/cinar/indicator/blob/master/helper/abs.go#L15>)
129138

@@ -1041,20 +1050,24 @@ type Number interface {
10411050
```
10421051

10431052
<a name="Report"></a>
1044-
## type [Report](<https://github.com/cinar/indicator/blob/master/helper/report.go#L53-L55>)
1053+
## type [Report](<https://github.com/cinar/indicator/blob/master/helper/report.go#L48-L54>)
10451054

10461055
Report generates an HTML file containing an interactive chart that visually represents the provided data and annotations.
10471056

10481057
The generated HTML file can be opened in a web browser to explore the data visually, interact with the chart elements, and view the associated annotations.
10491058

10501059
```go
10511060
type Report struct {
1052-
// contains filtered or unexported fields
1061+
Title string
1062+
Date <-chan time.Time
1063+
Columns []ReportColumn
1064+
Views [][]int
1065+
DateFormat string
10531066
}
10541067
```
10551068

10561069
<a name="NewReport"></a>
1057-
### func [NewReport](<https://github.com/cinar/indicator/blob/master/helper/report.go#L60>)
1070+
### func [NewReport](<https://github.com/cinar/indicator/blob/master/helper/report.go#L59>)
10581071

10591072
```go
10601073
func NewReport(title string, date <-chan time.Time) *Report
@@ -1063,7 +1076,7 @@ func NewReport(title string, date <-chan time.Time) *Report
10631076
NewReport takes a channel of time as the time axis and returns a new instance of the Report struct. This instance can later be used to add data and annotations and subsequently generate a report.
10641077

10651078
<a name="Report.AddChart"></a>
1066-
### func \(\*Report\) [AddChart](<https://github.com/cinar/indicator/blob/master/helper/report.go#L76>)
1079+
### func \(\*Report\) [AddChart](<https://github.com/cinar/indicator/blob/master/helper/report.go#L74>)
10671080

10681081
```go
10691082
func (r *Report) AddChart() int
@@ -1072,7 +1085,7 @@ func (r *Report) AddChart() int
10721085
AddChart adds a new chart to the report and returns its unique identifier. This identifier can be used later to refer to the chart and add columns to it.
10731086

10741087
<a name="Report.AddColumn"></a>
1075-
### func \(\*Report\) [AddColumn](<https://github.com/cinar/indicator/blob/master/helper/report.go#L83>)
1088+
### func \(\*Report\) [AddColumn](<https://github.com/cinar/indicator/blob/master/helper/report.go#L81>)
10761089

10771090
```go
10781091
func (r *Report) AddColumn(column ReportColumn, charts ...int)
@@ -1081,7 +1094,7 @@ func (r *Report) AddColumn(column ReportColumn, charts ...int)
10811094
AddColumn adds a new data column to the specified charts. If no chart is specified, it will be added to the main chart.
10821095

10831096
<a name="Report.WriteToFile"></a>
1084-
### func \(\*Report\) [WriteToFile](<https://github.com/cinar/indicator/blob/master/helper/report.go#L111>)
1097+
### func \(\*Report\) [WriteToFile](<https://github.com/cinar/indicator/blob/master/helper/report.go#L109>)
10851098

10861099
```go
10871100
func (r *Report) WriteToFile(fileName string) error
@@ -1090,7 +1103,7 @@ func (r *Report) WriteToFile(fileName string) error
10901103
WriteToFile writes the generated report content to a file with the specified name. This allows users to conveniently save the report for later viewing or analysis.
10911104

10921105
<a name="Report.WriteToWriter"></a>
1093-
### func \(\*Report\) [WriteToWriter](<https://github.com/cinar/indicator/blob/master/helper/report.go#L99>)
1106+
### func \(\*Report\) [WriteToWriter](<https://github.com/cinar/indicator/blob/master/helper/report.go#L97>)
10941107

10951108
```go
10961109
func (r *Report) WriteToWriter(writer io.Writer) error
@@ -1099,7 +1112,7 @@ func (r *Report) WriteToWriter(writer io.Writer) error
10991112
WriteToWriter writes the report content to the provided io.Writer. This allows the report to be sent to various destinations, such as a file, a network socket, or even the standard output.
11001113

11011114
<a name="ReportColumn"></a>
1102-
## type [ReportColumn](<https://github.com/cinar/indicator/blob/master/helper/report.go#L23-L35>)
1115+
## type [ReportColumn](<https://github.com/cinar/indicator/blob/master/helper/report.go#L28-L40>)
11031116

11041117
ReportColumn defines the interface that all report data columns must implement. This interface ensures that different types of data columns can be used consistently within the report generation process.
11051118

pre-commit.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ gosec ./...
3131

3232
revive -config=revive.toml ./...
3333
staticcheck ./...
34-
35-
for package in "${PACKAGES[@]}";
36-
do
37-
echo Package "$package"
38-
gomarkdoc --output "$package"/README.md ./"$package"
39-
done
34+
gomarkdoc ./...
4035

4136
markdownfmt -w README.md
4237

strategy/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (a *AndStrategy) Report(c <-chan *asset.Snapshot) *helper.Report
250250
Report processes the provided asset snapshots and generates a report annotated with the recommended actions.
251251

252252
<a name="Backtest"></a>
253-
## type [Backtest](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L44-L65>)
253+
## type [Backtest](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L44-L68>)
254254

255255
Backtest function rigorously evaluates the potential performance of the specified strategies applied to a defined set of assets. It generates comprehensive visual representations for each strategy\-asset pairing.
256256

@@ -271,12 +271,15 @@ type Backtest struct {
271271

272272
// WriteStrategyReports indicates whether the individual strategy reports should be generated.
273273
WriteStrategyReports bool
274+
275+
// DateFormat is the date format that is used in the reports.
276+
DateFormat string
274277
// contains filtered or unexported fields
275278
}
276279
```
277280

278281
<a name="NewBacktest"></a>
279-
### func [NewBacktest](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L89>)
282+
### func [NewBacktest](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L92>)
280283

281284
```go
282285
func NewBacktest(repository asset.Repository, outputDir string) *Backtest
@@ -285,7 +288,7 @@ func NewBacktest(repository asset.Repository, outputDir string) *Backtest
285288
NewBacktest function initializes a new backtest instance.
286289

287290
<a name="Backtest.Run"></a>
288-
### func \(\*Backtest\) [Run](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L105>)
291+
### func \(\*Backtest\) [Run](<https://github.com/cinar/indicator/blob/master/strategy/backtest.go#L109>)
289292

290293
```go
291294
func (b *Backtest) Run() error

trend/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func (h *Hma[T]) String() string
682682
String is the string representation of the HMA.
683683

684684
<a name="Kama"></a>
685-
## type [Kama](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L39-L48>)
685+
## type [Kama](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L38-L47>)
686686

687687
Kama represents the parameters for calculating the Kaufman's Adaptive Moving Average \(KAMA\). It is a type of moving average that adapts to market noise or volatility. It tracks prices closely during periods of small price swings and low noise.
688688

@@ -715,7 +715,7 @@ type Kama[T helper.Number] struct {
715715
```
716716

717717
<a name="NewKama"></a>
718-
### func [NewKama](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L51>)
718+
### func [NewKama](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L50>)
719719

720720
```go
721721
func NewKama[T helper.Number]() *Kama[T]
@@ -724,7 +724,7 @@ func NewKama[T helper.Number]() *Kama[T]
724724
NewKama function initializes a new KAMA instance with the default parameters.
725725

726726
<a name="NewKamaWith"></a>
727-
### func [NewKamaWith](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L60>)
727+
### func [NewKamaWith](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L59>)
728728

729729
```go
730730
func NewKamaWith[T helper.Number](erPeriod, fastScPeriod, slowScPeriod int) *Kama[T]
@@ -733,7 +733,7 @@ func NewKamaWith[T helper.Number](erPeriod, fastScPeriod, slowScPeriod int) *Kam
733733
NewKamaWith function initializes a new KAMA instance with the given parameters.
734734

735735
<a name="Kama[T].Compute"></a>
736-
### func \(\*Kama\[T\]\) [Compute](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L69>)
736+
### func \(\*Kama\[T\]\) [Compute](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L68>)
737737

738738
```go
739739
func (k *Kama[T]) Compute(closings <-chan T) <-chan T
@@ -742,7 +742,7 @@ func (k *Kama[T]) Compute(closings <-chan T) <-chan T
742742
Compute function takes a channel of numbers and computes the KAMA over the specified period.
743743

744744
<a name="Kama[T].IdlePeriod"></a>
745-
### func \(\*Kama\[T\]\) [IdlePeriod](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L138>)
745+
### func \(\*Kama\[T\]\) [IdlePeriod](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L134>)
746746

747747
```go
748748
func (k *Kama[T]) IdlePeriod() int
@@ -751,7 +751,7 @@ func (k *Kama[T]) IdlePeriod() int
751751
IdlePeriod is the initial period that KAMA yield any results.
752752

753753
<a name="Kama[T].String"></a>
754-
### func \(\*Kama\[T\]\) [String](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L143>)
754+
### func \(\*Kama\[T\]\) [String](<https://github.com/cinar/indicator/blob/master/trend/kama.go#L139>)
755755

756756
```go
757757
func (k *Kama[T]) String() string

0 commit comments

Comments
 (0)