importsort-d

Sort and format imports in DLang
Log | Files | Refs | README

commit 6de3c189b7678ec47cebaf2de8d69bcb2e79f4cb
parent a26b48c2509075bcc5c124d92a576e5152837999
Author: Friedel Schön <derfriedmundschoen@gmail.com>
Date:   Mon, 24 Oct 2022 13:05:37 +0200

Merge branch 'docs'

Diffstat:
A_config.yml | 13+++++++++++++
A_layouts/default.html | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/tips-tricks.md | 2++
Aindex.md | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 197 insertions(+), 0 deletions(-)

diff --git a/_config.yml b/_config.yml @@ -0,0 +1,13 @@ +# The page configuation for Jekyll (GitHub Pages) + +remote_theme: pages-themes/minimal@v0.2.0 +plugins: + - jekyll-remote-theme + +show_downloads: true +logo: /assets/importsort-d.png +dub_url: https://code.dlang.org/packages/importsort-d/ +github: + zip_url: https://github.com/friedelschoen/importsort-d/zipball/master + tar_url: https://github.com/friedelschoen/importsort-d/tarball/master + owner_name: Friedel Sch&ouml;n diff --git a/_layouts/default.html b/_layouts/default.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<html lang="{{ site.lang | default: " en-US" }}"> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + {% seo %} + <link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}"> + <!--[if lt IE 9]> + <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script> + <![endif]--> + {% include head-custom.html %} + + <style> + header { + width: 360px; + } + + header .downloads { + width: 360px; + } + + .wrapper { + width: 950px; + } + </style> +</head> + +<body> + <div class="wrapper"> + <header> + <h1><a href="{{ '/' | absolute_url }}">{{ site.title | default: site.github.repository_name }}</a></h1> + + {% if site.logo %} + <img src="{{ site.logo | relative_url }}" alt="Logo" /> + {% endif %} + + <p>{{ site.description | default: site.github.project_tagline }}</p> + + <p> + <a href="https://code.dlang.org/packages/importsort-d/"> + <img src="https://img.shields.io/dub/v/importsort-d?color=b03931" /></a> + <img src="https://img.shields.io/dub/l/importsort-d" /> + <img src="https://img.shields.io/github/commit-activity/m/friedelschoen/importsort-d" /> + </p> + + {% if site.github.is_user_page %} + <p class="view"><a href="{{ site.github.owner_url }}">View My GitHub Profile</a></p> + {% endif %} + + {% if site.show_downloads %} + <ul class="downloads"> + <li><a href="{{ site.github.zip_url }}">Download <strong>ZIP File</strong></a></li> + <li><a href="{{ site.github.tar_url }}">Download <strong>TAR Ball</strong></a></li> + <li><a href="{{ site.github.repository_url }}">View On <strong>GitHub</strong></a></li> + <li><a href="{{ site.dub_url }}">View On <strong>DUB.pm</strong></a></li> + </ul> + {% endif %} + + <!--<ul> + <li><a href='https://importsort-d.dpldocs.info/'>Documentation</a></li> + <li><a href='changelog'>Changelog</a></li> + <li><a href='add-to-editor'>Add to your Editor</a></li> + </ul>--> + </header> + <section> + {{ content }} + </section> + <footer> + {% if site.github.is_project_page %} + <p>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></p> + {% endif %} + <p><small>Hosted on GitHub Pages &mdash; Theme by <a + href="https://github.com/orderedlist">orderedlist</a></small></p> + </footer> + </div> + <script src="{{ '/assets/js/scale.fix.js' | relative_url }}"></script> +</body> + +</html> +\ No newline at end of file diff --git a/docs/tips-tricks.md b/docs/tips-tricks.md @@ -0,0 +1 @@ +# Coming soon +\ No newline at end of file diff --git a/index.md b/index.md @@ -0,0 +1,98 @@ +# Sort Imports for [D](https://dlang.org/) + +`sortimport-d` can sort your dozens of `import`'s in a `.d` file (no matter where) + +## Installation + +### Prerequisite + +- [`dub`](https://dub.pm/) + +### Building from HEAD + +Get the repository with `git` and compile everything with `dub` +``` +$ git clone https://github.com/friedelschoen/importsort-d +$ cd importsort-d +$ dub build +``` + +If everything went fine, there should be a binary at `bin/importsort-d`. + +Copy this into a directory included in `$PATH` (`/usr/bin` for example) to make this command work globally. + +### Building with DUB + +``` +$ dub fetch importsort-d +$ dub run importsort-d -- --help +``` + +This won't install the command globally, you always have to run `dub run importsort-d <args>` + +## Usage + +``` +$ importsort-d [-h] [-v] [-r] [-m] [-i] [-o <out>] [-k] [-a] [-r] <input...> +``` +`input` may be omitted or set to `-` to read from STDIN + +| option | description | +| --------------------- | ---------------------------------------------- | +| `-h, --help` | prints a help message | +| `-v, --verbose` | prints useful debug messages | +| | | +| `-k, --keep` | keeps the line as-is instead of formatting | +| `-a, --attribute` | public and static imports first | +| `-b, --binding` | sorts by binding rather then the original | +| `-m, --merge` | merge imports which uses same file | +| | | +| `-r, --recursive` | recursively search in directories | +| `-i, --inline` | changes the input | +| `-o, --output <path>` | writes to `path` rather then writing to STDOUT | + +## Documentation + +Look at the documentation on [`dpldocs.info`](https://importsort-d.dpldocs.info/), if you want to use this project in code. + +## FAQ + +For example, how to add `importsort-d` to Visual Studio Code and other: [go here](/docs/tips-tricks) + +## ToDo's + +- [x] recursive searching (`v0.2.0`) +- [x] merge imports (`v0.3.0`) +- [ ] watch-mode (struggling with save-timings - can clear files) + - you can add importsort-d into your onSave-hooks (e. g. [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) on VSCode) +- [ ] support multiple imports in one line (demilited by `;`) +- [ ] stripping unused imports (maybe) + +> you got some ideas? Issue them! + +## Changelog + +### `v0.1.0` +- the very first version +- not a lot is implemented + +### `v0.2.0` +- added `--recursive` (see above) +- option `--keep` becomes disabling formatting +- option `--inline` doen't copy the original but creates a `*.new` and renames it afterwards +- option `--original` becomes `--binding` and sorts by original by default +- refactoring code + +### `v0.3.0` +- added `--merge` (see above) + +### `v0.3.1` +- added documentation for contributers (or people who wan't to see my code) + +## License + +This whole project is licensed under the beautiful terms of the `zlib-license`. + +Further information [here](LICENSE). + +> made with love and a lot of cat memes +\ No newline at end of file