Skip to content

Commit 6ec3016

Browse files
committed
Merge pull request #20 from jmikola/docs
Create gh-pages docs with MkDocs and ApiGen
2 parents d28345d + 24042d1 commit 6ec3016

File tree

7 files changed

+204
-84
lines changed

7 files changed

+204
-84
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
apigen.phar
12
composer.lock
23
phpunit.xml
4+
site
35
vendor
6+

Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.PHONY: apigen composer test docs mkdocs
2+
3+
COMPOSER_ARGS=update --no-interaction --prefer-source
4+
PHPUNIT_ARGS=--process-isolation
5+
6+
composer:
7+
@command -v composer >/dev/null 2>&1; \
8+
if test $$? -eq 0; then \
9+
composer $(COMPOSER_ARGS); \
10+
elif test -r composer.phar; then \
11+
php composer.phar $(COMPOSER_ARGS); \
12+
else \
13+
echo >&2 "Cannot find composer; aborting."; \
14+
false; \
15+
fi
16+
17+
test: composer
18+
@command -v phpunit >/dev/null 2>&1; \
19+
if test $$? -eq 0; then \
20+
phpunit $(PHPUNIT_ARGS); \
21+
elif test -r phpunit.phar; then \
22+
php phpunit.phar $(PHPUNIT_ARGS); \
23+
else \
24+
echo >&2 "Cannot find phpunit; aborting."; \
25+
false; \
26+
fi
27+
28+
apigen:
29+
@command -v apigen >/dev/null 2>&1; \
30+
if test $$? -eq 0; then \
31+
apigen generate; \
32+
elif test -r apigen.phar; then \
33+
php apigen.phar generate; \
34+
else \
35+
echo >&2 "Cannot find apigen; aborting."; \
36+
false; \
37+
fi
38+
39+
mkdocs:
40+
@command -v mkdocs >/dev/null 2>&1; \
41+
if test $$? -eq 0; then \
42+
mkdocs build --clean; \
43+
else \
44+
echo >&2 "Cannot find mkdocs; aborting."; \
45+
false; \
46+
fi
47+
48+
docs: mkdocs apigen
49+
50+
publish-docs: docs
51+
mkdocs gh-deploy
52+
@echo "If origin is your local fork, you may need to run:"
53+
@echo " " git push REMOTE gh-pages:gh-pages

README.md

+6-84
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# GeoJson
1+
# GeoJson PHP Library
22

33
[![Build Status](https://travis-ci.org/jmikola/geojson.png?branch=master)](https://travis-ci.org/jmikola/geojson)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jmikola/geojson/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jmikola/geojson/?branch=master)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/jmikola/geojson/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/jmikola/geojson/?branch=master)
46

57
This library implements the
68
[GeoJSON format specification](http://www.geojson.org/geojson-spec.html).
@@ -20,87 +22,7 @@ The library is published as a
2022
$ composer require "jmikola/geojson=~1.0"
2123
```
2224

23-
## Usage
25+
## More Resources
2426

25-
Classes in this library are immutable.
26-
27-
### GeoJson Constructors
28-
29-
Geometry objects are constructed using a single coordinates array. This may be
30-
a tuple in the case of a `Point`, an array of tuples for a `LineString`, etc.
31-
Constructors for each class will validate the coordinates array and throw an
32-
`InvalidArgumentException` on error.
33-
34-
More primitive geometry objects may also be used for constructing complex
35-
objects. For instance, a `LineString` may be constructed from an array of
36-
`Point` objects.
37-
38-
Feature objects are constructed from a geometry object, associative properties
39-
array, and an identifier, all of which are optional.
40-
41-
Feature and geometry collection objects are constructed from an array of their
42-
respective types.
43-
44-
#### Specifying a Bounding Box or CRS
45-
46-
All GeoJson constructors support `BoundingBox` and `CoordinateReferenceSystem`
47-
objects as optional arguments beyond those explicitly listed in their prototype.
48-
These objects may appear in any order *after* the explicit arguments.
49-
50-
```php
51-
$crs = new \GeoJson\CoordinateReferenceSystem\Named('urn:ogc:def:crs:OGC:1.3:CRS84');
52-
$box = new \GeoJson\BoundingBox([-180, -90, 180, 90]);
53-
$point = new \GeoJson\Geometry\Point([0, 0], $crs, $box);
54-
```
55-
56-
Note that the `Feature` class is unique in that it has three arguments, all with
57-
default values. In order to construct a `Feature` with a bounding box or CRS,
58-
all three arguments must be explicitly listed (e.g. with `null` placeholders).
59-
60-
```php
61-
$box = new \GeoJson\BoundingBox([-180, -90, 180, 90]);
62-
$feature = new \GeoJson\Feature\Feature(null, null, null, $box);
63-
```
64-
65-
### JSON Serialization
66-
67-
Each class in the library implements PHP 5.4's
68-
[JsonSerializable](http://php.net/manual/en/class.jsonserializable.php)
69-
interface, which allows objects to be passed directly to `json_encode()`.
70-
71-
```php
72-
$point = new \GeoJson\Geometry\Point([1, 1]);
73-
$json = json_encode($point);
74-
```
75-
76-
Printing the `$json` variable would yield (sans whitespace):
77-
78-
```json
79-
{
80-
"type": "Point",
81-
"coordinates": [1, 1]
82-
}
83-
```
84-
85-
A stub interface is included for compatibility with PHP 5.3, although lack of
86-
core support for the interface means that `jsonSerialize()` will need to be
87-
manually called and its return value passed to `json_encode()`.
88-
89-
### JSON Unserialization
90-
91-
The core `GeoJson` class implements an internal `JsonUnserializable` interface,
92-
which defines a static factory method, `jsonUnserialize()`, that can be used to
93-
create objects from the return value of `json_decode()`.
94-
95-
```php
96-
$json = '{ "type": "Point", "coordinates": [1, 1] }';
97-
$json = json_decode($json);
98-
$point = \GeoJson\GeoJson::jsonUnserialize($json);
99-
```
100-
101-
If errors are encountered during unserialization, an `UnserializationException`
102-
will be thrown by `jsonUnserialize()`. Possible errors include:
103-
104-
* Missing properties (e.g. `type` is not present)
105-
* Unexpected values (e.g. `coordinates` property is not an array)
106-
* Unsupported `type` string when parsing a GeoJson object or CRS
27+
* [Documentation](http://jmikola.github.io/geojson)
28+
* [API reference](http://jmikola.github.io/geojson/api)

apigen.neon

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
source:
2+
- src
3+
4+
destination: site/api
5+
6+
charset:
7+
- UTF-8
8+
9+
main: GeoJSON PHP library
10+
title: GeoJSON PHP library
11+
baseUrl: http://jmikola.github.io/geojson
12+
googleCseId: null
13+
googleAnalytics: null
14+
templateTheme: bootstrap
15+
templateConfig: null
16+
17+
deprecated: false
18+
internal: false
19+
todo: false
20+
21+
php: false
22+
tree: true
23+
download: false

docs/index.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# GeoJson PHP Library
2+
3+
This library implements the
4+
[GeoJSON format specification](http://www.geojson.org/geojson-spec.html).
5+
6+
The `GeoJson` namespace includes classes for each data structure defined in the
7+
GeoJSON specification. Core GeoJSON objects include geometries, features, and
8+
collections. Geometries range from primitive points to more complex polygons.
9+
Classes also exist for bounding boxes and coordinate reference systems.
10+
11+
## Installation
12+
13+
The library is published as a
14+
[package](https://packagist.org/packages/jmikola/geojson) and is installable via
15+
[Composer](http://getcomposer.org/):
16+
17+
```
18+
$ composer require "jmikola/geojson=^1.0"
19+
```
20+
21+
## API Documentation
22+
23+
API documentation may be found [here](./api).
24+
25+
## Usage
26+
27+
Classes in this library are immutable.
28+
29+
### GeoJson Constructors
30+
31+
Geometry objects are constructed using a single coordinates array. This may be
32+
a tuple in the case of a `Point`, an array of tuples for a `LineString`, etc.
33+
Constructors for each class will validate the coordinates array and throw an
34+
`InvalidArgumentException` on error.
35+
36+
More primitive geometry objects may also be used for constructing complex
37+
objects. For instance, a `LineString` may be constructed from an array of
38+
`Point` objects.
39+
40+
Feature objects are constructed from a geometry object, associative properties
41+
array, and an identifier, all of which are optional.
42+
43+
Feature and geometry collection objects are constructed from an array of their
44+
respective types.
45+
46+
#### Specifying a Bounding Box or CRS
47+
48+
All GeoJson constructors support `BoundingBox` and `CoordinateReferenceSystem`
49+
objects as optional arguments beyond those explicitly listed in their prototype.
50+
These objects may appear in any order *after* the explicit arguments.
51+
52+
```php
53+
$crs = new \GeoJson\CoordinateReferenceSystem\Named('urn:ogc:def:crs:OGC:1.3:CRS84');
54+
$box = new \GeoJson\BoundingBox([-180, -90, 180, 90]);
55+
$point = new \GeoJson\Geometry\Point([0, 0], $crs, $box);
56+
```
57+
58+
Note that the `Feature` class is unique in that it has three arguments, all with
59+
default values. In order to construct a `Feature` with a bounding box or CRS,
60+
all three arguments must be explicitly listed (e.g. with `null` placeholders).
61+
62+
```php
63+
$box = new \GeoJson\BoundingBox([-180, -90, 180, 90]);
64+
$feature = new \GeoJson\Feature\Feature(null, null, null, $box);
65+
```
66+
67+
### JSON Serialization
68+
69+
Each class in the library implements PHP 5.4's
70+
[JsonSerializable](http://php.net/manual/en/class.jsonserializable.php)
71+
interface, which allows objects to be passed directly to `json_encode()`.
72+
73+
```php
74+
$point = new \GeoJson\Geometry\Point([1, 1]);
75+
$json = json_encode($point);
76+
```
77+
78+
Printing the `$json` variable would yield (sans whitespace):
79+
80+
```json
81+
{
82+
"type": "Point",
83+
"coordinates": [1, 1]
84+
}
85+
```
86+
87+
A stub interface is included for compatibility with PHP 5.3, although lack of
88+
core support for the interface means that `jsonSerialize()` will need to be
89+
manually called and its return value passed to `json_encode()`.
90+
91+
### JSON Unserialization
92+
93+
The core `GeoJson` class implements an internal `JsonUnserializable` interface,
94+
which defines a static factory method, `jsonUnserialize()`, that can be used to
95+
create objects from the return value of `json_decode()`.
96+
97+
```php
98+
$json = '{ "type": "Point", "coordinates": [1, 1] }';
99+
$json = json_decode($json);
100+
$point = \GeoJson\GeoJson::jsonUnserialize($json);
101+
```
102+
103+
If errors are encountered during unserialization, an `UnserializationException`
104+
will be thrown by `jsonUnserialize()`. Possible errors include:
105+
106+
* Missing properties (e.g. `type` is not present)
107+
* Unexpected values (e.g. `coordinates` property is not an array)
108+
* Unsupported `type` string when parsing a GeoJson object or CRS

docs/pretty.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$(document).ready(function() {
2+
$('pre code').parent().addClass('prettyprint well');
3+
prettyPrint();
4+
});

mkdocs.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
site_name: "GeoJSON PHP library"
2+
repo_url: https://github.com/jmikola/geojson
3+
theme: spacelab
4+
pages:
5+
- [index.md, Home]
6+
extra_javascript:
7+
- pretty.js

0 commit comments

Comments
 (0)