Skip to content

Commit 9b9ad1b

Browse files
Update documentation
1 parent 6914ab9 commit 9b9ad1b

File tree

4 files changed

+60
-41
lines changed

4 files changed

+60
-41
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Thank you for your understanding. 🙏
2222
- **Ask questions** if something is unclear
2323
- **Star ⭐ the repository** if you find it useful
2424

25-
Your feedback is very valuable, even if direct code contributions aren’t accepted.
25+
Your feedback is very valuable, even if direct code contributions aren’t accepted **for now**.

README.md

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# JFileTreePrettyPrint
2-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ComputerDaddyGuy_JFileTreePrettyPrinter&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ComputerDaddyGuy_JFileTreePrettyPrinter)
32
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ComputerDaddyGuy_JFileTreePrettyPrinter&metric=alert_status&token=42442b67d269c6a17b4578ba2d87731c92b8922a)](https://sonarcloud.io/summary/new_code?id=ComputerDaddyGuy_JFileTreePrettyPrinter)
43
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ComputerDaddyGuy_JFileTreePrettyPrinter&metric=security_rating&token=42442b67d269c6a17b4578ba2d87731c92b8922a)](https://sonarcloud.io/summary/new_code?id=ComputerDaddyGuy_JFileTreePrettyPrinter)
54
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ComputerDaddyGuy_JFileTreePrettyPrinter&metric=vulnerabilities&token=42442b67d269c6a17b4578ba2d87731c92b8922a)](https://sonarcloud.io/summary/new_code?id=ComputerDaddyGuy_JFileTreePrettyPrinter)
@@ -9,7 +8,7 @@
98
[![Javadoc](https://javadoc.io/badge2/io.github.computerdaddyguy/jfiletreeprettyprinter/javadoc.svg?color=blue)](https://javadoc.io/doc/io.github.computerdaddyguy/jfiletreeprettyprinter)
109
[![Apache License 2.0](https://img.shields.io/:license-Apache%20License%202.0-blue.svg)](https://github.com/computerdaddyguy/jfiletreeprettyprinter/blob/main/LICENSE)
1110

12-
**A lightweight Java library for printing directory structures in a clean, tree-like format.**
11+
**A lightweight and flexible Java library to pretty-print directory structures — ideal for documentation, project overviews, or CLI tools.**
1312

1413
Supports various [options](#options) to customize the directories scanning and rendering:
1514
- Filtering & sorting files and folders
@@ -31,13 +30,23 @@ Supports various [options](#options) to customize the directories scanning and r
3130
> [!IMPORTANT]
3231
> Complete documentation available in [wiki](https://github.com/ComputerDaddyGuy/JFileTreePrettyPrinter/wiki).
3332
33+
* [Why use JFileTreePrettyPrinter?](#why-use-jfiletreeprettyprinter)
34+
* [Requirements](#requirements)
3435
* [Import dependency](#import-dependency)
3536
* [Basic usage](#basic-usage)
36-
* [Options](#options)
37-
* [Changelog](#changelog)
38-
* [Roadmap](#roadmap)
39-
* [License](#license)
40-
* [Contributing & Contact](#contributing--contact)
37+
* [Customization options](#customization-options)
38+
* [Project Information](#project-information)
39+
40+
# Why use JFileTreePrettyPrinter?
41+
Unlike a plain recursive `Files.walk()`, this library:
42+
- Prints **visually appealing** directory trees.
43+
- Allows **rich customization** (filters, sorts, emojis, compacting, tree style).
44+
- Supports **dynamic child limits** and **custom extensions** per line.
45+
- Is **dependency-free** (on runtime) and compatible with **Java 21+**.
46+
47+
# Requirements
48+
- **Java 21 or later**
49+
- No runtime dependencies
4150

4251
# Import dependency
4352
For Maven, import this dependency to your `pom.xml`:
@@ -51,20 +60,21 @@ For Maven, import this dependency to your `pom.xml`:
5160
```
5261

5362
For Gradle:
54-
```
63+
```groovy
5564
implementation "io.github.computerdaddyguy:jfiletreeprettyprinter:0.0.5"
5665
```
5766

58-
# Basic Usage
67+
# Basic usage
5968
```java
6069
// Example: BasicUsage.java
61-
var printer = FileTreePrettyPrinter.createDefault();
62-
var tree = printer.prettyPrint("src/example/resources/base");
63-
System.out.println(tree);
70+
var printer = FileTreePrettyPrinter.createDefault(); // Create a printer with default options
71+
var tree = printer.prettyPrint("src/example/resources/base"); // Pretty print the target folder
72+
System.out.println(tree); // Admire the result!
6473
```
6574

6675
Result:
67-
```
76+
77+
```text
6878
base/
6979
├─ businessPlan.pdf
7080
├─ businessProject.pdf
@@ -84,7 +94,7 @@ base/
8494
> [!NOTE]
8595
> In case of error while reading directories or files, an [UncheckedIOException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/UncheckedIOException.html) is thrown.
8696
87-
# Options
97+
# Customization options
8898

8999
* [Filtering](#filtering)
90100
* [Sorting](#sorting)
@@ -98,8 +108,8 @@ base/
98108
## Filtering
99109
Files and directories can be selectively included or excluded using a custom `PathMatcher`.
100110

101-
Filtering is independant for files & directories. Files are filtered only if their parent directory pass the directory filter.
102-
If none of some directory's children match, the directory is still displayed.
111+
Filtering applies independently to files and directories. Files are filtered only if their parent directory passes the directory filter.
112+
If none of a directorys children match, the directory is still displayed.
103113

104114
The `PathMatchers` class provides several ready-to-use methods for creating and combining common matchers.
105115

@@ -116,7 +126,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
116126
)
117127
.build();
118128
```
119-
```
129+
130+
```text
120131
filtering/
121132
├─ dir_with_java_files/
122133
│ ├─ file_B.java
@@ -140,7 +151,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
140151
.customizeOptions(options -> options.sort(PathSorts.DIRECTORY_FIRST))
141152
.build();
142153
```
143-
```
154+
155+
```text
144156
sorting/
145157
├─ c_dir/
146158
│ └─ c_file
@@ -156,7 +168,7 @@ sorting/
156168

157169
## Emojis ❤️
158170
If your terminal supports them, you can choose to use emojis.
159-
Folders will have the "📂" emoji, and files will have an emoji depending on their extension (when applicable).
171+
Folders use the 📂 emoji, and files will have an emoji depending on their extension (when applicable).
160172

161173
```java
162174
// Example: Emojis.java
@@ -165,8 +177,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
165177
.build();
166178
```
167179

168-
```
169-
// Run Emojis.java example for exhaustive list
180+
```text
181+
// Run Emojis.java example for the full list of emoji mappings
170182
📂 emojis/
171183
├─ 📦 file.zip
172184
├─ 🐳 Dockerfile
@@ -186,7 +198,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
186198
> *Idea for a future version: option to allow custom emoji mapping*
187199
188200
## Child limit
189-
You can set a fixed limit to the number of children displayed for each directory. Each directory and file that pass filter (if set) counts for one.
201+
You can set a fixed limit to the number of children displayed for each directory. Each directory and file that pass the filter (if set) counts for one.
190202

191203
```java
192204
// Example: ChildLimitStatic.java
@@ -195,7 +207,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
195207
.build();
196208
```
197209

198-
```
210+
```text
199211
child_limit_static/
200212
├─ file_0_1
201213
├─ folder_1/
@@ -213,7 +225,7 @@ child_limit_static/
213225
```
214226

215227
Or you can also set a limitation function, to dynamically choose the number of children displayed in each directory.
216-
It avoids cluttering the whole console with known large folders (e.g. `node_modules`) but continue to pretty print normally other folders.
228+
This avoids cluttering the result with known large folders (e.g. `node_modules`) while continuing to pretty-print other folders normally.
217229

218230
Use the `ChildLimits` class to help you build the limit function that fits your needs.
219231

@@ -227,7 +239,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
227239
.customizeOptions(options -> options.withChildLimit(childLimit))
228240
.build();
229241
```
230-
```
242+
243+
```text
231244
child_limit_dynamic/
232245
├─ file_0_1
233246
├─ folder_1/
@@ -257,15 +270,15 @@ Function<Path, String> lineExtension = LineExtensions.builder()
257270
.add(PathMatchers.hasRelativePathMatchingGlob(printedPath, "src/main/java/api"), "\t\t\t// All API code: controllers, etc.")
258271
.add(PathMatchers.hasRelativePathMatchingGlob(printedPath, "src/main/java/domain"), "\t\t\t// All domain code: value objects, etc.")
259272
.add(PathMatchers.hasRelativePathMatchingGlob(printedPath, "src/main/java/infra"), "\t\t\t// All infra code: database, email service, etc.")
260-
.add(PathMatchers.hasRelativePathMatchingGlob(printedPath, "src/main/java/api"), "\t\t\t// All API code: controllers, etc.")
261273
.add(PathMatchers.hasNameMatchingGlob("*.properties"), "\t// Config file")
262274
.build();
263275

264276
var prettyPrinter = FileTreePrettyPrinter.builder()
265277
.customizeOptions(options -> options.withLineExtension(lineExtension))
266278
.build();
267279
```
268-
```
280+
281+
```text
269282
line_extension/
270283
└─ src/
271284
└─ main/
@@ -281,15 +294,16 @@ line_extension/
281294
```
282295

283296
## Compact directories
284-
Directories chain with single directory child are fully expanded by default, but you can compact them into a single tree entry.
297+
Directory chains with a single child directory are fully expanded by default, but you can inline them into a single tree entry.
285298

286299
```java
287300
// Example: CompactDirectories.java
288301
var prettyPrinter = FileTreePrettyPrinter.builder()
289302
.customizeOptions(options -> options.withCompactDirectories(true))
290303
.build();
291304
```
292-
```
305+
306+
```text
293307
single_directory_child/
294308
├─ file1
295309
├─ file2
@@ -308,7 +322,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
308322
.customizeOptions(options -> options.withMaxDepth(3))
309323
.build();
310324
```
311-
```
325+
326+
```text
312327
max_depth/
313328
└─ level1/
314329
├─ file1#1
@@ -331,7 +346,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
331346
.build();
332347
```
333348

334-
```
349+
```text
335350
tree_format/
336351
|-- file_1
337352
|-- file_2
@@ -343,15 +358,19 @@ tree_format/
343358
> [!TIP]
344359
> *Idea for a future version: option to allow usage of custom format*
345360
346-
# Changelog
347-
See [CHANGELOG.md](CHANGELOG.md) for released versions.
361+
# Project Information
362+
363+
## Changelog
364+
See [CHANGELOG.md](CHANGELOG.md) for a list of released versions and detailed changes.
348365

349-
# Roadmap
350-
See [ROADMAP.md](ROADMAP.md) for upcoming features.
366+
## Roadmap
367+
See [ROADMAP.md](ROADMAP.md) to discover planned features and upcoming improvements.
351368

352-
# License
353-
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
369+
## License
370+
This project is licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
354371

355-
# Contributing & Contact
356-
For any questions or feedback, please open an issue on this repository.
372+
## Contributing & Contact
373+
For any questions or feedback please open an issue on this repository, as detailed in [CONTRIBUTING.md](CONTRIBUTING.md).
357374

375+
---
376+
Made with ❤️ by [ComputerDaddyGuy](https://github.com/ComputerDaddyGuy)

assets/project-structure.png

-51.1 KB
Loading

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<packaging>jar</packaging>
1111
<name>JFileTreePrettyPrinter</name>
12-
<description>A lightweight Java library for printing directory structures in a clean, tree-like format.</description>
12+
<description>A lightweight and flexible Java library to pretty-print directory structures — ideal for documentation, project overviews, or CLI tools.</description>
1313
<url>https://github.com/ComputerDaddyGuy/JFileTreePrettyPrinter</url>
1414

1515
<licenses>

0 commit comments

Comments
 (0)