Skip to content

Commit 0d67c94

Browse files
committed
Added readthedocs documentation.
1 parent 9010f64 commit 0d67c94

File tree

8 files changed

+283
-0
lines changed

8 files changed

+283
-0
lines changed

.readthedocs.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the "docs/" directory with Sphinx
19+
sphinx:
20+
configuration: docs/source/conf.py
21+
22+
# Optionally build your docs in additional formats such as PDF and ePub
23+
# formats:
24+
# - pdf
25+
# - epub
26+
27+
# Optional but recommended, declare the Python requirements required
28+
# to build your documentation
29+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
30+
python:
31+
install:
32+
- requirements: docs/requirements.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Defining the exact version will make sure things don't break
2+
sphinx-pdj-theme==0.4.0
3+
myst-parser==2.0.0
4+
markdown-it-py==3.0.0
5+
sphinx-copybutton==0.5.2

docs/source/code.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# IP2Location PHP API
2+
3+
## Database Class
4+
```{py:class} Database(database_file_path, file_mode)
5+
Load the IP2Location BIN database.
6+
7+
:param str database_file_path: (Required) The file path links to IP2Location BIN databases.
8+
:param str file_mode: (Optional) Caching mode (one of FILE_IO, MEMORY_CACHE, or SHARED_MEMORY).
9+
```
10+
11+
```{py:function} getPackageVersion()
12+
Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
13+
14+
:return: Returns the package version.
15+
:rtype: string
16+
```
17+
18+
```{py:function} getModuleVersion()
19+
Return the version of module.
20+
21+
:return: Returns the module version.
22+
:rtype: string
23+
```
24+
25+
```{py:function} getDatabaseVersion()
26+
Return the database's compilation date as a string of the form 'YYYY-MM-DD'.
27+
28+
:return: Returns the database version.
29+
:rtype: string
30+
```
31+
32+
```{py:function} lookup(ip_address)
33+
Retrieve geolocation information for an IP address.
34+
35+
:param str ip_address: (Required) The IP address (IPv4 or IPv6).
36+
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
37+
:rtype: array
38+
39+
**RETURN FIELDS**
40+
41+
| Field Name | Description |
42+
| ---------------- | ------------------------------------------------------------ |
43+
| countryCode | Two-character country code based on ISO 3166. |
44+
| countryName | Country name based on ISO 3166. |
45+
| regionName | Region or state name. |
46+
| cityName | City name. |
47+
| isp | Internet Service Provider or company\'s name. |
48+
| domain | Internet domain name associated with IP address range. |
49+
| usageType | Usage type classification of ISP or company. |
50+
| asn | Autonomous system number (ASN). |
51+
| as | Autonomous system (AS) name. |
52+
| lastSeen | Proxy last seen in days. |
53+
| threat | Security threat reported. |
54+
| proxyType | Type of proxy. |
55+
| provider | Name of VPN provider if available. |
56+
```

docs/source/conf.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
# Read https://www.sphinx-doc.org/en/master/usage/configuration.html for more options available
3+
4+
import sphinx_pdj_theme
5+
6+
# -- Project information
7+
8+
project = 'IP2Proxy PHP'
9+
copyright = '2023, IP2Location'
10+
author = 'IP2Location'
11+
12+
release = '0.1.0'
13+
version = '0.1.0'
14+
15+
# -- General configuration
16+
17+
extensions = [
18+
'sphinx.ext.duration',
19+
'sphinx.ext.doctest',
20+
'myst_parser',
21+
'sphinx_copybutton',
22+
]
23+
24+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
25+
26+
myst_enable_extensions = [
27+
"colon_fence",
28+
"deflist",
29+
"fieldlist",
30+
]
31+
32+
# templates_path = ['_templates']
33+
34+
# -- Options for HTML output
35+
36+
html_theme = 'sphinx_pdj_theme'
37+
html_theme_path = [sphinx_pdj_theme.get_html_theme_path()]
38+
39+
# PDJ theme options, see the list of available options here: https://github.com/jucacrispim/sphinx_pdj_theme/blob/master/sphinx_pdj_theme/theme.conf
40+
html_theme_options = {
41+
# Hide the name of the project above the search bar
42+
'home_link': 'hide'
43+
}
44+
45+
# The name of an image file (relative to this directory) to place at the top
46+
# of the sidebar.
47+
html_logo = 'images/ipl-logo-square-1200.png'
48+
49+
# Favicon
50+
html_favicon = 'images/favicon.ico'
51+
52+
html_title = "IP2Location Python"

docs/source/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# IP2Proxy PHP Module
2+
[![Latest Stable Version](https://img.shields.io/packagist/v/ip2location/ip2proxy-php.svg)](https://packagist.org/packages/ip2location/ip2proxy-php)
3+
[![Total Downloads](https://img.shields.io/packagist/dt/ip2location/ip2proxy-php.svg?style=flat-square)](https://packagist.org/packages/ip2location/ip2proxy-php)
4+
5+
This module allows user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits. It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
6+
7+
* Free IP2Proxy BIN Data: https://lite.ip2location.com
8+
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/proxy-database
9+
10+
11+
12+
## Table of contents
13+
```{eval-rst}
14+
.. toctree::
15+
16+
self
17+
quickstart
18+
code
19+
```

docs/source/quickstart.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Quickstart
2+
3+
## Dependencies
4+
5+
This library requires IP2Location BIN database to function. You may download the BIN database at
6+
7+
- IP2Location LITE BIN Data (Free): <https://lite.ip2location.com>
8+
- IP2Location Commercial BIN Data (Comprehensive):
9+
<https://www.ip2location.com>
10+
11+
:::{note}
12+
An outdated BIN database was provided in the data folder for your testing. You are recommended to visit the above links to download the latest BIN database.
13+
:::
14+
15+
## Installation
16+
17+
Install this package using the command as below:
18+
19+
```
20+
composer require ip2location/ip2proxy-php
21+
```
22+
23+
## Sample Codes
24+
25+
### Query geolocation information from BIN database
26+
27+
You can query the geolocation information from the IP2Location BIN database as below:
28+
29+
```php
30+
require 'vendor/autoload.php';
31+
32+
$db = new \IP2Proxy\Database('vendor/ip2location/ip2proxy-php/data/PX11.SAMPLE.BIN', \IP2PROXY\Database::FILE_IO);
33+
34+
$records = $db->lookup('1.0.0.8', \IP2PROXY\Database::ALL);
35+
36+
echo '<p><strong>IP Address: </strong>' . $records['ipAddress'] . '</p>';
37+
echo '<p><strong>IP Number: </strong>' . $records['ipNumber'] . '</p>';
38+
echo '<p><strong>IP Version: </strong>' . $records['ipVersion'] . '</p>';
39+
echo '<p><strong>Country Code: </strong>' . $records['countryCode'] . '</p>';
40+
echo '<p><strong>Country: </strong>' . $records['countryName'] . '</p>';
41+
echo '<p><strong>State: </strong>' . $records['regionName'] . '</p>';
42+
echo '<p><strong>City: </strong>' . $records['cityName'] . '</p>';
43+
44+
/*
45+
Type of proxy: VPN, TOR, DCH, PUB, WEB, RES (RES available in PX11 only)
46+
*/
47+
echo '<p><strong>Proxy Type: </strong>' . $records['proxyType'] . '</p>';
48+
49+
/*
50+
Returns -1 on errors
51+
Returns 0 is not proxy
52+
Return 1 if proxy
53+
Return 2 if it's data center IP
54+
*/
55+
echo '<p><strong>Is Proxy: </strong>' . $records['isProxy'] . '</p>';
56+
echo '<p><strong>ISP: </strong>' . $records['isp'] . '</p>';
57+
echo '<p><strong>Domain: </strong>' . $records['domain'] . '</p>';
58+
echo '<p><strong>Usage Type: </strong>' . $records['usageType'] . '</p>';
59+
echo '<p><strong>ASN: </strong>' . $records['asn'] . '</p>';
60+
echo '<p><strong>AS: </strong>' . $records['as'] . '</p>';
61+
echo '<p><strong>Last Seen: </strong>' . $records['lastSeen'] . '</p>';
62+
echo '<p><strong>Threat: </strong>' . $records['threat'] . '</p>';
63+
echo '<p><strong>Provider: </strong>' . $records['provider'] . '</p>';
64+
```

0 commit comments

Comments
 (0)