Skip to content

Commit 92e5b6b

Browse files
committed
docs(adptool): reformat README for improved readability and compliance
- Restructured content to fit within 80-character line limit - Added blank lines to separate sections and improve readability - Updated code examples and command syntax for better clarity - Improved consistency in list formatting and indentation
1 parent b72bba1 commit 92e5b6b

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

README.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,34 @@
55
[![Go Report Card](https://goreportcard.com/badge/github.com/origadmin/adptool)](https://goreportcard.com/report/github.com/origadmin/adptool)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
`adptool` is a powerful and highly configurable Go code generator that automates the creation of adapter code. It helps you seamlessly integrate third-party libraries and internal modules by generating type aliases, function wrappers, and method proxies based on a clear and powerful configuration system.
8+
`adptool` is a powerful and highly configurable Go code generator that automates the creation of adapter code. It helps
9+
you seamlessly integrate third-party libraries and internal modules by generating type aliases, function wrappers, and
10+
method proxies based on a clear and powerful configuration system.
911

1012
## Core Features
1113

1214
- **Automated Adapter Generation**: Eliminates boilerplate code by automatically generating type-safe adapters.
1315
- **Flexible Configuration**: Use YAML, JSON, or TOML to define your code generation rules.
1416
- **Hierarchical Rule System**: Apply rules globally, per-package, or for specific types, functions, and members.
15-
- **Granular Renaming Control**: Precisely control naming with prefixes, suffixes, regular expressions, and explicit from/to mappings.
16-
- **Simple Source-Code Directives**: Use simple `//go:adapter` comments to mark packages for adaptation without cluttering your code.
17-
- **Dependency Decoupling**: Isolate your core logic from specific third-party implementations, making upgrades and replacements easier.
17+
- **Granular Renaming Control**: Precisely control naming with prefixes, suffixes, regular expressions, and explicit
18+
from/to mappings.
19+
- **Simple Source-Code Directives**: Use simple `//go:adapter` comments to mark packages for adaptation without
20+
cluttering your code.
21+
- **Dependency Decoupling**: Isolate your core logic from specific third-party implementations, making upgrades and
22+
replacements easier.
1823

1924
## Installation
2025

2126
#### From Source
27+
2228
```bash
2329
go install github.com/origadmin/adptool/cmd/adptool@latest
2430
```
2531

2632
#### Pre-compiled Binaries
27-
Visit the [**Releases Page**](https://github.com/origadmin/adptool/releases) to download a pre-compiled binary for your platform.
33+
34+
Visit the [**Releases Page**](https://github.com/origadmin/adptool/releases) to download a pre-compiled binary for your
35+
platform.
2836

2937
---
3038

@@ -38,6 +46,7 @@ Create a file (e.g., `adapters/directives.go`) to tell `adptool` which package y
3846

3947
```go
4048
// adapters/directives.go
49+
4150
package myapp
4251

4352
//go:adapter:package github.com/foo/bar
@@ -103,29 +112,32 @@ adptool [flags] [arguments...]
103112

104113
**Arguments**
105114

106-
- `[arguments...]` (required): One or more Go source files or directories to scan for directives. Supports `...` wildcard syntax (e.g., `./...`).
115+
- `[arguments...]` (required): One or more Go source files or directories to scan for directives. Supports `...`
116+
wildcard syntax (e.g., `./...`).
107117

108118
**Flags**
109119

110120
- `-c, --config <file_path>`
111-
- Specifies the path to a configuration file (YAML, JSON, or TOML). If not provided, `adptool` automatically searches for `.adptool.yaml` (or `.json`, `.toml`) in the current directory and a `./configs` subdirectory.
121+
- Specifies the path to a configuration file (YAML, JSON, or TOML). If not provided, `adptool` automatically
122+
searches for `.adptool.yaml` (or `.json`, `.toml`) in the current directory and a `./configs` subdirectory.
112123

113124
- `--copyright-holder <string>`
114-
- Injects a copyright notice into the generated file's header.
125+
- Injects a copyright notice into the generated file's header.
115126

116127
- `-o, --output <file_path>` (Planned)
117-
- Specifies a single file path for all generated output code. Currently, output files are generated automatically alongside their source directive files.
128+
- Specifies a single file path for all generated output code. Currently, output files are generated automatically
129+
alongside their source directive files.
118130

119131
- `-v, --verbose` (Planned)
120-
- Enables verbose logging for debugging.
132+
- Enables verbose logging for debugging.
121133

122134
### Directives
123135

124136
Directives are comments in your Go source code that `adptool` uses as entry points.
125137

126138
- `//go:adapter:package <import_path> [alias]`
127-
- This is the primary directive. It tells `adptool` to adapt the package specified by `<import_path>`.
128-
- You can optionally provide a custom `[alias]` for the package in the generated code.
139+
- This is the primary directive. It tells `adptool` to adapt the package specified by `<import_path>`.
140+
- You can optionally provide a custom `[alias]` for the package in the generated code.
129141

130142
```go
131143
// Adapt the package, letting the generator create an alias.
@@ -137,7 +149,8 @@ Directives are comments in your Go source code that `adptool` uses as entry poin
137149

138150
## Configuration
139151

140-
`adptool` is controlled by a configuration file (e.g., `.adptool.yaml`). For fully-commented examples, see the [**`./examples`**](./examples) directory.
152+
`adptool` is controlled by a configuration file (e.g., `.adptool.yaml`). For fully-commented examples, see the [*
153+
*`./examples`**](./examples) directory.
141154

142155
Here is a high-level overview of the main configuration sections:
143156

@@ -146,16 +159,17 @@ Here is a high-level overview of the main configuration sections:
146159
- `defaults`: Sets the default behavior for how rules are applied (e.g., `prepend` or `replace` for prefixes).
147160
- `props`: A list of key-value pairs that can be used as variables in other parts of the configuration.
148161
- `packages`: A list of package-specific rules that override the global rules.
149-
- `types`, `functions`, `variables`, `constants`: These sections contain the core renaming rules for different kinds of Go declarations.
162+
- `types`, `functions`, `variables`, `constants`: These sections contain the core renaming rules for different kinds of
163+
Go declarations.
150164

151165
### Rule Priority
152166

153167
For any given symbol, rules are resolved and applied in the following order:
154168

155-
1. **Ignore**: If a symbol matches an `ignores` rule, it is skipped entirely.
156-
2. **Explicit**: If an `explicit` rule (`from`/`to`) matches the symbol, it is renamed, and **no further rules apply**.
157-
3. **Prefix & Suffix**: If no explicit rule matches, the resolved `prefix` and `suffix` are applied.
158-
4. **Regex**: The resolved `regex` rules are applied to the result of the previous step.
169+
1. **Ignore**: If a symbol matches an `ignores` rule, it is skipped entirely.
170+
2. **Explicit**: If an `explicit` rule (`from`/`to`) matches the symbol, it is renamed, and **no further rules apply**.
171+
3. **Prefix & Suffix**: If no explicit rule matches, the resolved `prefix` and `suffix` are applied.
172+
4. **Regex**: The resolved `regex` rules are applied to the result of the previous step.
159173

160174
## Contributing
161175

0 commit comments

Comments
 (0)