Skip to content

Commit d7171c5

Browse files
committed
Misc doc changes
Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the main source doc for this Elixir library which leverage on latest ExDoc features.
1 parent 6550ac3 commit d7171c5

File tree

7 files changed

+84
-54
lines changed

7 files changed

+84
-54
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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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

1010
# Where 3rd-party dependencies like ExDoc output generated docs.
11-
/doc
11+
/doc/
1212

1313
# Ignore .fetch files in case you like to edit your project deps locally.
1414
/.fetch
@@ -19,7 +19,11 @@ erl_crash.dump
1919
# Also ignore archive artifacts (built via "mix archive.build").
2020
*.ez
2121

22-
/.elixir_ls
22+
# Ignore package tarball (built via "mix hex.build").
23+
geo_postgis-*.tar
24+
25+
# Temporary files for e.g. tests.
26+
/tmp/
2327

2428
# Emacs project file
2529
.projectile

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# GeoPostGIS
22

33
[![Build Status](https://travis-ci.org/bryanjos/geo_postgis.svg?branch=master)](https://travis-ci.org/bryanjos/geo_postgis)
4-
[![Hex.pm](https://img.shields.io/hexpm/v/geo_postgis.svg)](https://hex.pm/packages/geo_postgis)
4+
[![Module Version](https://img.shields.io/hexpm/v/geo_postgis.svg)](https://hex.pm/packages/geo_postgis)
5+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/geo_postgis/)
6+
[![Total Download](https://img.shields.io/hexpm/dt/geo_postgis.svg)](https://hex.pm/packages/geo_postgis)
7+
[![License](https://img.shields.io/hexpm/l/geo_postgis.svg)](https://github.com/bryanjos/geo_postgis/blob/master/LICENSE)
8+
[![Last Updated](https://img.shields.io/github/last-commit/bryanjos/geo_postgis.svg)](https://github.com/bryanjos/geo_postgis/commits/master)
59

610
Postgrex extension for the PostGIS data types. Uses the [geo](https://github.com/bryanjos/geo) library
711

8-
[Documentation](http://hexdocs.pm/geo_postgis)
9-
1012
## Installation
1113

12-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
13-
by adding `geo_postgis` to your list of dependencies in `mix.exs`:
14+
The package can be installed by adding `:geo_postgis` to your list of
15+
dependencies in `mix.exs`:
1416

1517
```elixir
1618
def deps do
17-
[{:geo_postgis, "~> 3.1"}]
19+
[
20+
{:geo_postgis, "~> 3.1"}
21+
]
1822
end
1923
```
2024

@@ -23,7 +27,11 @@ Make sure PostGIS extension to your database is installed. More information [her
2327
### Optional Configuration
2428

2529
```elixir
26-
# When a binary is passed to `Geo.PostGIS.Geometry.cast/1` implementation of `Ecto.Type.cast/1`, it is assumed to be a GeoJSON string. When this happens, geo_postgis will use Poison, by default, to convert the binary to a map and then convert that map to one of the Geo structs. If in these cases you would like to use a different JSON parser, you can set the config below.
30+
# When a binary is passed to `Geo.PostGIS.Geometry.cast/1` implementation of
31+
# `Ecto.Type.cast/1`, it is assumed to be a GeoJSON string. When this happens,
32+
# geo_postgis will use Poison, by default, to convert the binary to a map and
33+
# then convert that map to one of the Geo structs. If in these cases you would
34+
# like to use a different JSON parser, you can set the config below.
2735

2836
# config.exs
2937
config :geo_postgis,
@@ -32,7 +40,7 @@ config :geo_postgis,
3240

3341
## Examples
3442

35-
### Postgrex Extension for the PostGIS data types, Geometry and Geography
43+
Postgrex Extension for the PostGIS data types, Geometry and Geography:
3644

3745
```elixir
3846
Postgrex.Types.define(MyApp.PostgresTypes, [Geo.PostGIS.Extension], [])
@@ -57,7 +65,7 @@ Postgrex.Connection.query(pid, "SELECT * FROM point_test")
5765
rows: [{42, %Geo.Point{coordinates: {30.0, -90.0}, srid: 4326 }}]}}
5866
```
5967

60-
### Use with Ecto Referencing [the documentation](https://hexdocs.pm/ecto_sql/Ecto.Adapters.Postgres.html#module-extensions):
68+
Use with [Ecto](https://hexdocs.pm/ecto_sql/Ecto.Adapters.Postgres.html#module-extensions):
6169

6270
```elixir
6371
#If using with Ecto, you may want something like thing instead
@@ -102,7 +110,7 @@ defmodule Repo.Migrations.Init do
102110
end
103111
```
104112

105-
### Ecto migrations can also use more elaborate [Postgis GIS Objects](http://postgis.net/docs/using_postgis_dbmanagement.html#RefObject). These types are useful for enforcing constraints on {Lng,Lat} (order matters), or ensuring that a particular projection/coordinate system/format is used.
113+
Ecto migrations can also use more elaborate [PostGIS GIS Objects](http://postgis.net/docs/using_postgis_dbmanagement.html#RefObject). These types are useful for enforcing constraints on `{Lng,Lat}` (order matters), or ensuring that a particular projection/coordinate system/format is used.
106114

107115
```elixir
108116
defmodule Repo.Migrations.AdvancedInit do
@@ -127,7 +135,7 @@ defmodule Repo.Migrations.AdvancedInit do
127135
end
128136
```
129137

130-
Be sure to enable the Postgis extension if you haven't already done so:
138+
Be sure to enable the PostGIS extension if you haven't already done so:
131139

132140
```elixir
133141
defmodule MyApp.Repo.Migrations.EnablePostgis do
@@ -143,7 +151,7 @@ defmodule MyApp.Repo.Migrations.EnablePostgis do
143151
end
144152
```
145153

146-
### [Postgis functions](http://postgis.net/docs/manual-1.3/ch06.html) can also be used in ecto queries. Currently only the OpenGIS functions are implemented. Have a look at [lib/geo_postgis.ex](lib/geo_postgis.ex) for the implemented functions. You can use them like:
154+
[PostGIS functions](http://postgis.net/docs/manual-1.3/ch06.html) can also be used in Ecto queries. Currently only the OpenGIS functions are implemented. Have a look at [lib/geo_postgis.ex](lib/geo_postgis.ex) for the implemented functions. You can use them like:
147155

148156
```elixir
149157
defmodule Example do
@@ -155,7 +163,6 @@ defmodule Example do
155163
query
156164
|> Repo.one
157165
end
158-
159166
end
160167
```
161168

@@ -168,3 +175,10 @@ After you got the dependencies via `mix deps.get` make sure that:
168175
* your `postgres` db user can login without a password or you set the `PGPASSWORD` environment variable appropriately
169176

170177
Then you can run the tests as you are used to with `mix test`.
178+
179+
180+
## Copyright and License
181+
182+
Copyright (c) 2017 Bryan Joseph
183+
184+
Released under the MIT License, which can be found in the repository in [`LICENSE`](https://github.com/bryanjos/geo_postgis/blob/master/LICENSE).

lib/geo_postgis.ex

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
defmodule Geo.PostGIS do
22
@moduledoc """
3-
Postgis functions that can used in ecto queries
4-
[PostGIS Function Documentation](http://postgis.net/docs/manual-1.3/ch06.html)
3+
PostGIS functions that can used in ecto queries
4+
[PostGIS Function Documentation](http://postgis.net/docs/manual-1.3/ch06.html).
55
6-
Currently only the OpenGIS functions are implemented
6+
Currently only the OpenGIS functions are implemented.
7+
8+
## Examples
79
8-
ex.
910
defmodule Example do
1011
import Ecto.Query
1112
import Geo.PostGIS
1213
1314
def example_query(geom) do
1415
from location in Location, limit: 5, select: st_distance(location.geom, ^geom)
1516
end
16-
1717
end
18+
1819
"""
1920

2021
defmacro st_transform(wkt, srid) do
@@ -24,9 +25,9 @@ defmodule Geo.PostGIS do
2425
defmacro st_distance(geometryA, geometryB) do
2526
quote do: fragment("ST_Distance(?,?)", unquote(geometryA), unquote(geometryB))
2627
end
27-
28+
2829
@doc """
29-
Casts the 2 geometries given to geographies in order to return distance in meters
30+
Casts the 2 geometries given to geographies in order to return distance in meters.
3031
"""
3132
defmacro st_distance_in_meters(geometryA, geometryB) do
3233
quote do:
@@ -56,7 +57,7 @@ defmodule Geo.PostGIS do
5657
end
5758

5859
@doc """
59-
Casts the 2 geometries given to geographies in order to check for distance in meters
60+
Casts the 2 geometries given to geographies in order to check for distance in meters.
6061
"""
6162
defmacro st_dwithin_in_meters(geometryA, geometryB, float) do
6263
quote do:
@@ -382,7 +383,7 @@ defmodule Geo.PostGIS do
382383
quote do: fragment("ST_BdMPolyFromText(?, ?)", unquote(wkt), unquote(srid))
383384
end
384385

385-
defmacro st_flip_coordinates(geometryA) do
386+
defmacro st_flip_coordinates(geometryA) do
386387
quote do: fragment("ST_FlipCoordinates(?)", unquote(geometryA))
387388
end
388389
end

lib/geo_postgis/extension.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
defmodule Geo.PostGIS.Extension do
2-
@behaviour Postgrex.Extension
3-
42
@moduledoc """
5-
PostGIS extension for Postgrex. Supports Geometry and Geography data types
3+
PostGIS extension for Postgrex. Supports Geometry and Geography data types.
4+
5+
## Examples
6+
7+
Create a new Postgrex Types module:
68
7-
#Create a new Postgrex Types module:
89
Postgrex.Types.define(MyApp.PostgresTypes, [Geo.PostGIS.Extension], [])
910
10-
#If using with Ecto, you may want something like thing instead
11+
If using with Ecto, you may want something like thing instead:
12+
1113
Postgrex.Types.define(MyApp.PostgresTypes,
1214
[Geo.PostGIS.Extension] ++ Ecto.Adapters.Postgres.extensions(),
1315
json: Poison)
@@ -36,6 +38,8 @@ defmodule Geo.PostGIS.Extension do
3638
3739
"""
3840

41+
@behaviour Postgrex.Extension
42+
3943
@geo_types [
4044
Geo.GeometryCollection,
4145
Geo.LineString,

mix.exs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
11
defmodule GeoPostgis.Mixfile do
22
use Mix.Project
33

4+
@source_url "https://github.com/bryanjos/geo_postgis"
5+
@version "3.3.1"
6+
47
def project do
58
[
69
app: :geo_postgis,
7-
version: "3.3.1",
10+
version: @version,
811
elixir: "~> 1.7",
9-
build_embedded: Mix.env() == :prod,
1012
start_permanent: Mix.env() == :prod,
13+
name: "GeoPostGIS",
1114
deps: deps(),
12-
description: description(),
1315
package: package(),
14-
name: "GeoPostGIS",
16+
docs: docs(),
1517
elixirc_paths: elixirc_paths(Mix.env()),
16-
source_url: source_url()
1718
]
1819
end
1920

2021
def application do
2122
[extra_applications: [:logger]]
2223
end
2324

24-
defp source_url do
25-
"https://github.com/bryanjos/geo_postgis"
26-
end
27-
2825
defp elixirc_paths(:test), do: ["lib", "test/support"]
2926
defp elixirc_paths(_), do: ["lib"]
3027

31-
defp description do
32-
"""
33-
PostGIS extension for Postgrex.
34-
"""
35-
end
36-
3728
defp deps do
3829
[
3930
{:geo, "~> 3.3"},
4031
{:postgrex, "~> 0.14"},
41-
{:ex_doc, "~> 0.21.0", only: :dev},
32+
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
4233
{:ecto_sql, "~> 3.0", optional: true, only: :test},
4334
{:poison, "~> 2.2 or ~> 3.0 or ~> 4.0", optional: true},
4435
{:jason, "~> 1.0", optional: true}
4536
]
4637
end
4738

4839
defp package do
49-
# These are the default files included in the package
5040
[
41+
description: "PostGIS extension for Postgrex.",
5142
files: ["lib", "mix.exs", "README.md", "CHANGELOG.md"],
5243
maintainers: ["Bryan Joseph"],
5344
licenses: ["MIT"],
54-
links: %{"GitHub" => source_url()}
45+
links: %{"GitHub" => @source_url}
46+
]
47+
end
48+
49+
defp docs do
50+
[
51+
extras: ["CHANGELOG.md", "README.md"],
52+
main: "readme",
53+
source_url: @source_url,
54+
source_ref: "v#{@version}",
55+
formatters: ["html"]
5556
]
5657
end
5758
end

mix.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"db_connection": {:hex, :db_connection, "2.2.0", "e923e88887cd60f9891fd324ac5e0290954511d090553c415fbf54be4c57ee63", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "bdf196feedfa6b83071e808b2b086fb113f8a1c4c7761f6eff6fe4b96aba0086"},
44
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm", "52694ef56e60108e5012f8af9673874c66ed58ac1c4fae9b5b7ded31786663f5"},
55
"earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"},
6+
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
67
"ecto": {:hex, :ecto, "3.3.0", "9193e261d25c1814324d0b3304fccbadab840b286d270c3b75dfd28c30a3ae15", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "f50c944ea0de690510ed90b266c4ff55a6f15ce09b891d77681861ce2f150484"},
78
"ecto_sql": {:hex, :ecto_sql, "3.3.0", "6023515613a28541af9d163fda047f67747b75b23a00d7d8bf5009d46a6ee4d0", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cddbff19dd6ac5c786259efa1429269687ffd8299b235f039d4a11e0706f6e40"},
8-
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"},
9+
"ex_doc": {:hex, :ex_doc, "0.24.1", "15673de99154f93ca7f05900e4e4155ced1ee0cd34e0caeee567900a616871a4", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "07972f17bdf7dc7b5bd76ec97b556b26178ed3f056e7ec9288eb7cea7f91cce2"},
910
"geo": {:hex, :geo, "3.3.3", "1119302b20d21515fbcec0a180b82653524067873ed333e7fa1f55e39959d702", [:mix], [], "hexpm", "8297ae0ac5ce47bb608b2bc8a63030460020ae537de9464a7a652f25baf6d2c1"},
1011
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"},
11-
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"},
12-
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
13-
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"},
12+
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
13+
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
14+
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
15+
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
1416
"poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"},
1517
"postgrex": {:hex, :postgrex, "0.15.3", "5806baa8a19a68c4d07c7a624ccdb9b57e89cbc573f1b98099e3741214746ae4", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4737ce62a31747b4c63c12b20c62307e51bb4fcd730ca0c32c280991e0606c90"},
1618
"telemetry": {:hex, :telemetry, "0.4.1", "ae2718484892448a24470e6aa341bc847c3277bfb8d4e9289f7474d752c09c7f", [:rebar3], [], "hexpm", "4738382e36a0a9a2b6e25d67c960e40e1a2c95560b9f936d8e29de8cd858480f"},

0 commit comments

Comments
 (0)