Skip to content

Commit af791af

Browse files
committed
add generic api guide
1 parent 279ba78 commit af791af

File tree

6 files changed

+92
-10
lines changed

6 files changed

+92
-10
lines changed

docs/api.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!-- meta -->
2+
<title>
3+
commitlog | manual
4+
</title>
5+
<meta name="description" content="commits to changelog generator">
6+
<!-- meta end -->
7+
8+
### [commitlog](/)
9+
10+
[Home](/) [Manual](/manual) [Download &darr;](/download) [API](/api)
11+
12+
# API
13+
14+
### General Guide
15+
16+
commitlog also comes as a pkg that you could reuse to modify the behaviour of
17+
the commands and this is very limited at the moment since I'm still working on
18+
the best way to get plugins to work with the original CLI instead of having to
19+
write your own version of commitlog.
20+
21+
The pkg contains the 2 base command's creators and behaviour modifiers, or more
22+
commonly known as the golang options pattern.
23+
24+
Briefly put, You have one function that takes in unlimited amount of functions
25+
as parameter with each of these parameter functions being able to modify the
26+
behaviour of the returned instance.
27+
28+
Easy way to explain this is with an example of the `releaser` API
29+
30+
```go
31+
package main
32+
33+
import (
34+
"log"
35+
36+
"github.com/barelyhuman/commitlog/pkg"
37+
)
38+
39+
func main() {
40+
versionString := "v0.0.1"
41+
releaser, _ := pkg.CreateNewReleaser(
42+
versionString,
43+
pkg.WithMajorIncrement(),
44+
)
45+
46+
log.Println(releaser.String())
47+
48+
}
49+
```
50+
51+
here the `pkg.CreateNewReleaser` takes in one mandatory value which is the
52+
`versionString` and the 2nd parameter is optional here.
53+
54+
Though, since we wish for the releaser to have a custom behaviour everytime the
55+
flags change, instead of writing entire functionalities inside various releaser
56+
functions, which would look like so
57+
58+
```go
59+
releaser.IncrementMajor()
60+
releaser.IncrementMinor()
61+
```
62+
63+
I'd be unable to expose the builders / option functions out to the public for
64+
them to write custom behaviours that work directly with the `struct` being used
65+
by commitlog itself and instead you'd be writing wrappers around existing
66+
functions. Thus, adding another layer of abstraction which isn't needed for
67+
something that wants to be extended.
68+
69+
This approach gives me the ability to expose a selected few properties for you
70+
to modify while writing your own builder/option function.
71+
72+
The only pointer functions that releaser has is the one's that'll help with
73+
printing or identifying the final version's state.
74+
75+
Since, you now know how the API is written, the go doc for this module should be
76+
able to help you with the remaining.
77+
78+
[godoc&nearr;](https://pkg.go.dev/github.com/barelyhuman/commitlog)
79+
80+
> **Note**: if the go doc still hasn't been generated for v2.0.0, please go
81+
> through the source code to help you with the implementation details

docs/download.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
### [commitlog](/)
99

10-
[Manual](/manual)\
11-
[Download &darr;](/download)
10+
[Home](/) [Manual](/manual) [Download &darr;](/download) [API](/api)
1211

1312
#### Downloads
1413

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
### [commitlog](/)
99

10-
[Manual](/manual)\
11-
[Download &darr;](/download)
10+
[Home](/) [Manual](/manual) [Download &darr;](/download) [API](/api)
1211

1312
#### Index
1413

@@ -123,4 +122,5 @@ PATH variables
123122

124123
<h4 id="license">License</h4>
125124

126-
commitlog is MIT Licensed and you can read the entire license in the [source code](https://github.com/barelyhuman/commitlog)
125+
commitlog is MIT Licensed and you can read the entire license in the
126+
[source code](https://github.com/barelyhuman/commitlog)

docs/manual.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
### [commitlog](/)
99

10-
[Manual](/manual)\
11-
[Download &darr;](/download)
10+
[Home](/) [Manual](/manual) [Download &darr;](/download) [API](/api)
1211

1312
# Manual
1413

@@ -20,6 +19,7 @@
2019
- [From a different repo](#from-a-different-repo)
2120
- [Categorize](#categorize)
2221
- [CLI](#cli)
22+
- [API](/api)
2323

2424
<h3 id="basics">Basics</h3>
2525

docs/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600;700&display=swap");
22

3-
43
:root {
54
--base: #fff;
65
--surface: #efefef;
@@ -9,7 +8,7 @@
98
--accent: dodgerblue;
109
}
1110

12-
@media (prefers-color-scheme:dark) {
11+
@media (prefers-color-scheme: dark) {
1312
:root {
1413
--base: #111;
1514
--surface: #333;
@@ -99,6 +98,7 @@ pre>code {
9998

10099
a {
101100
color: inherit;
101+
text-underline-offset: 4px;
102102
}
103103

104104
a:hover {

scripts/get-release-urls.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#!/usr/bin/env bash
23

34
curl -sL https://api.github.com/repos/barelyhuman/commitlog/releases | jq '[ .[0].assets[] | {name:.name,url:.url} ]' > api_urls.json
@@ -12,8 +13,9 @@ cat >./docs/download.md<<EOF
1213
1314
### [commitlog](/)
1415
15-
[Manual](/manual)
16+
[Manual](/manual)
1617
[Download &darr;](/download)
18+
[API](/api)
1719
1820
#### Downloads
1921

0 commit comments

Comments
 (0)