Skip to content

Commit 1b1b6d0

Browse files
committed
Misc doc changes (#22)
Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the source of truth for this Elixir library and leverage on latest features of ExDoc.
1 parent 327d3c9 commit 1b1b6d0

13 files changed

+144
-86
lines changed

.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.gitignore

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
# The directory Mix will write compiled artifacts to.
2-
/_build
2+
/_build/
33

44
# If you run "mix test --cover", coverage assets end up here.
5-
/cover
5+
/cover/
66

77
# The directory Mix downloads your dependencies sources to.
8-
/deps
8+
/deps/
99

10-
# Where 3rd-party dependencies like ExDoc output generated docs.
11-
/doc
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
1215

1316
# If the VM crashes, it generates a dump, let's ignore it too.
1417
erl_crash.dump
1518

1619
# Also ignore archive artifacts (built via "mix archive.build").
1720
*.ez
1821

19-
/.elixir_ls
22+
# Ignore package tarball (built via "mix hex.build").
23+
ecto-soft-delete-*.tar
24+
25+
# Temporary files, for example, from tests.
26+
/tmp/

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
## [2.0.1] - 2020-05-08
1313

14-
- Add logic to `Ecto.SoftDelete.Repo.prepare_query` to respect `where` clauses that explicitly include records where deleted_at is not nil
14+
- Add logic to `Ecto.SoftDelete.Repo.prepare_query` to respect `where` clauses
15+
that explicitly include records where deleted_at is not nil
1516

1617
## [2.0.0] - 2020-05-06
1718

@@ -22,16 +23,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2223

2324
### Added
2425

25-
- `Ecto.SoftDelete.Repo` for adding soft delete functions to repositories.
26+
- `Ecto.SoftDelete.Repo` for adding soft delete functions to repositories
2627

2728
## [1.0.0] - 2019-02-15
2829

2930
### Added
3031

3132
- Ecto 3 support
3233

33-
## [0.2.0]
34+
## [0.2.0] - 2018-12-31
3435

3536
### Fixed
3637

3738
- Missing license (MIT)
39+
40+
## [0.1.0] - 2017-12-20
41+
42+
- Initial release

CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Setup for Development
1+
# Contributing
22

3-
```
3+
## Setup for Development
4+
5+
```bash
46
git clone https://github.com/revelrylabs/ecto_soft_delete
57
mix deps.get
68
```
79

8-
# Submitting Changes
10+
## Submitting Changes
911

1012
1. Fork the repository.
1113
2. Set up the package per the instructions above and ensure `mix test`

LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.

LICENSE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright 2018 Revelry Labs LLC
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
1+
# EctoSoftDelete
2+
13
[![Build Status](https://travis-ci.org/revelrylabs/ecto_soft_delete.svg?branch=master)](https://travis-ci.org/revelrylabs/ecto_soft_delete)
2-
[![Hex.pm](https://img.shields.io/hexpm/dt/ecto_soft_delete.svg)](https://hex.pm/packages/ecto_soft_delete)
3-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
[![Coverage Status](https://opencov.prod.revelry.net/projects/21/badge.svg)](https://opencov.prod.revelry.net/projects/21)
5-
6-
# EctoSoftDelete
5+
[![Module Version](https://img.shields.io/hexpm/v/ecto_soft_delete.svg)](https://hex.pm/packages/ecto_soft_delete)
6+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ecto_soft_delete/)
7+
[![Total Download](https://img.shields.io/hexpm/dt/ecto_soft_delete.svg)](https://hex.pm/packages/ecto_soft_delete)
8+
[![License](https://img.shields.io/hexpm/l/ecto_soft_delete.svg)](https://github.com/revelrylabs/ecto_soft_delete/blob/master/LICENSE)
9+
[![Last Updated](https://img.shields.io/github/last-commit/revelrylabs/ecto_soft_delete.svg)](https://github.com/revelrylabs/ecto_soft_delete/commits/master)
710

811
Adds columns, fields, and queries for soft deletion with Ecto.
912

10-
[Documentation](https://hexdocs.pm/ecto_soft_delete)
13+
## Installation
14+
15+
The package can be installed by adding `:ecto_soft_delete` to your list of
16+
dependencies in `mix.exs`:
17+
18+
Add to mix.exs:
19+
20+
```elixir
21+
defp deps do
22+
[
23+
{:ecto_soft_delete, "~> 1.0"}
24+
]
25+
end
26+
```
27+
28+
and do:
29+
30+
```
31+
mix deps.get
32+
```
1133

1234
## Usage
1335

1436
### Migrations
1537

16-
In migrations for schemas to support soft deletion, import `Ecto.SoftDelete.Migration`. Next, add `soft_delete_columns()` when creating a table
38+
In migrations for schemas to support soft deletion, import
39+
`Ecto.SoftDelete.Migration`. Next, add `soft_delete_columns()` when creating a
40+
table:
1741

1842
```elixir
1943
defmodule MyApp.Repo.Migrations.CreateUser do
@@ -33,23 +57,26 @@ end
3357

3458
### Schemas
3559

36-
Import `Ecto.SoftDelete.Schema` into your Schema module, then add `soft_delete_schema()` to your schema
60+
Import `Ecto.SoftDelete.Schema` into your Schema module, then add
61+
`soft_delete_schema()` to your schema:
3762

3863
```elixir
39-
defmodule User do
40-
use Ecto.Schema
41-
import Ecto.SoftDelete.Schema
64+
defmodule User do
65+
use Ecto.Schema
66+
import Ecto.SoftDelete.Schema
4267

43-
schema "users" do
44-
field :email, :string
45-
soft_delete_schema()
46-
end
68+
schema "users" do
69+
field :email, :string
70+
soft_delete_schema()
4771
end
72+
end
4873
```
4974

5075
### Queries
5176

52-
To query for items that have not been deleted, use `with_undeleted(query)` which will filter out deleted items using the `deleted_at` column produced by the previous 2 steps
77+
To query for items that have not been deleted, use `with_undeleted(query)`
78+
which will filter out deleted items using the `deleted_at` column produced by
79+
the previous 2 steps:
5380

5481
```elixir
5582
import Ecto.SoftDelete.Query
@@ -60,10 +87,12 @@ query = from(u in User, select: u)
6087
results = Repo.all(query)
6188
```
6289

63-
## Repos
90+
### Repos
6491

6592
To support deletion in repos, just add `use Ecto.SoftDelete.Repo` to your repo.
66-
After that, the functions `soft_delete!/1`, `soft_delete/1` and `soft_delete_all/1` will be available for you.
93+
94+
After that, the functions `soft_delete!/1`, `soft_delete/1` and
95+
`soft_delete_all/1` will be available for you.
6796

6897
```elixir
6998
# repo.ex
@@ -88,31 +117,18 @@ post = Repo.get!(Post, 42)
88117
struct = Repo.soft_delete!(post)
89118
```
90119

91-
## Installation
92-
93-
Add to mix.exs:
94-
95-
```elixir
96-
defp deps do
97-
[{:ecto_soft_delete, "~> 1.0"}]
98-
end
99-
```
100-
101-
and do
102-
103-
```
104-
mix deps.get
105-
```
106-
107-
## Configuration
120+
## Contributing
108121

109-
There are currently no configuration options.
122+
Bug reports and pull requests are welcome on GitHub at
123+
https://github.com/revelrylabs/ecto_soft_delete. Check out
124+
[CONTRIBUTING.md](./CONTRIBUTING.md) for more info.
110125

111-
## Usage
126+
Everyone is welcome to participate in the project. We expect contributors to
127+
adhere the Contributor Covenant Code of Conduct (see [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)).
112128

113-
## Contributing
129+
## Copyright and License
114130

115-
Bug reports and pull requests are welcome on GitHub at https://github.com/revelrylabs/ecto_soft_delete. Check out [CONTRIBUTING.md](https://github.com/revelrylabs/ecto_soft_delete/blob/master/CONTRIBUTING.md) for more info.
131+
Copyright (c) 2018 Revelry Labs LLC
116132

117-
Everyone is welcome to participate in the project. We expect contributors to
118-
adhere the Contributor Covenant Code of Conduct (see [CODE_OF_CONDUCT.md](https://github.com/revelrylabs/ecto_soft_delete/blob/master/CODE_OF_CONDUCT.md)).
133+
This library is released under the MIT License. See the [LICENSE.md](./LICENSE.md) file
134+
for further details.

lib/ecto/soft_delete_migration.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
defmodule Ecto.SoftDelete.Migration do
22
@moduledoc """
3-
Contains functions to add soft delete columns to a table during migrations
3+
Contains functions to add soft delete columns to a table during migrations.
44
"""
55

66
use Ecto.Migration
77

88
@doc """
9-
Adds deleted_at column to a table. This column is used to track if an item is deleted or not and when
9+
Adds deleted_at column to a table.
10+
11+
This column is used to track if an item is deleted or not and when:
1012
1113
defmodule MyApp.Repo.Migrations.CreateUser do
1214
use Ecto.Migration

lib/ecto/soft_delete_query.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
defmodule Ecto.SoftDelete.Query do
22
@moduledoc """
3-
functions for querying data that is (or is not) soft deleted
3+
Functions for querying data that is (or is not) soft deleted.
44
"""
55

66
import Ecto.Query
77

88
@doc """
9-
Returns a query that searches only for undeleted items
9+
Returns a query that searches only for undeleted items.
1010
1111
query = from(u in User, select: u)
1212
|> with_undeleted

lib/ecto/soft_delete_repo.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ defmodule Ecto.SoftDelete.Repo do
2828

2929
@doc """
3030
Soft deletes a struct.
31+
3132
Updates the `deleted_at` field with the current datetime in UTC.
33+
3234
It returns `{:ok, struct}` if the struct has been successfully
3335
soft deleted or `{:error, changeset}` if there was a validation
3436
or a known constraint error.

lib/ecto/soft_delete_schema.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
defmodule Ecto.SoftDelete.Schema do
22
@moduledoc """
3-
Contains schema macros to add soft delete fields to a schema
3+
Contains schema macros to add soft delete fields to a schema.
44
"""
55

66
@doc """
7-
Adds the deleted_at column to a schema
7+
Adds the `deleted_at` column to a schema.
88
99
defmodule User do
1010
use Ecto.Schema

mix.exs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
defmodule EctoSoftDelete.Mixfile do
22
use Mix.Project
33

4+
@source_url "https://github.com/revelrylabs/ecto_soft_delete"
5+
@version "2.0.2"
6+
47
def project do
58
[
69
app: :ecto_soft_delete,
7-
version: "2.0.2",
10+
version: @version,
811
elixir: "~> 1.9",
912
elixirc_paths: elixirc_paths(Mix.env()),
1013
build_embedded: Mix.env() == :prod,
@@ -17,8 +20,8 @@ defmodule EctoSoftDelete.Mixfile do
1720
"coveralls.html": :test
1821
],
1922
deps: deps(),
23+
docs: docs(),
2024
package: package(),
21-
description: description()
2225
]
2326
end
2427

@@ -33,20 +36,15 @@ defmodule EctoSoftDelete.Mixfile do
3336
[
3437
{:ecto_sql, "~> 3.0"},
3538
{:postgrex, ">= 0.0.0", only: [:test]},
36-
{:ex_doc, "~> 0.16", only: [:dev, :test]},
39+
{:ex_doc, ">= 0.0.0", only: [:dev, :test]},
3740
{:credo, "~> 1.0", only: [:dev, :test]},
3841
{:excoveralls, "~> 0.8", only: [:dev, :test]}
3942
]
4043
end
4144

42-
defp description do
43-
"""
44-
Soft deletion with Ecto.
45-
"""
46-
end
47-
4845
defp package do
4946
[
47+
description: "Soft deletion with Ecto.",
5048
files: ["lib", "mix.exs", "README.md", "LICENSE", "CHANGELOG.md"],
5149
maintainers: ["Bryan Joseph", "Luke Ledet"],
5250
licenses: ["MIT"],
@@ -56,4 +54,20 @@ defmodule EctoSoftDelete.Mixfile do
5654
build_tools: ["mix"]
5755
]
5856
end
57+
58+
defp docs do
59+
[
60+
extras: [
61+
"CHANGELOG.md": [title: "Changelog"],
62+
"CONTRIBUTING.md": [title: "Contributing"],
63+
"CODE_OF_CONDUCT.md": [title: "Code of Conduct"],
64+
"LICENSE.md": [title: "License"],
65+
"README.md": [title: "Overview"]
66+
],
67+
main: "readme",
68+
source_url: @source_url,
69+
source_ref: "v#{@version}",
70+
formatters: ["html"]
71+
]
72+
end
5973
end

0 commit comments

Comments
 (0)