Skip to content

Commit 516da3e

Browse files
committed
Documentation improvements
1 parent 506b7d8 commit 516da3e

File tree

4 files changed

+94
-39
lines changed

4 files changed

+94
-39
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## Version 1.0.0 (2018-12-23)
3+
- Added support for TibiaData JSON parsing. To have interoperability between Tibia.com and TibiaData.
4+
- Added support for parsing Houses, House lists, World and World list
5+
- Added support for many missing attributes in Character and Guilds.
6+
- All objects are now serializable to JSON strings.
7+
28
## Version 0.1.0 (2018-08-17)
39
Initial release:
410
- Parses content from tibia.com

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ No fetching is done by this module, you must provide the html content.
99
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tibia.py.svg)
1010
![PyPI - License](https://img.shields.io/pypi/l/tibia.py.svg)
1111

12+
**Features:**
13+
14+
- Converts data into well-structured Python objects.
15+
- Type consistent attributes.
16+
- All objects can be converted to JSON strings.
17+
- Can be used with any networking library.
18+
- Support for characters, guilds, houses and worlds.
19+
1220
## Installing
1321
Install and update using pip
1422

@@ -36,7 +44,7 @@ async def get_character(name):
3644

3745
async with aiohttp.ClientSession() as session:
3846
async with session.get(url) as resp:
39-
content = await resp.text()
47+
content = await resp.text()
4048
character = tibiapy.Character.from_content(content)
4149
return character
4250

docs/index.rst

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,37 @@
22
sphinx-quickstart on Mon Aug 6 17:46:14 2018.
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
5-
.. currentmodule:: tibiapy
6-
7-
.. toctree::
8-
:hidden:
9-
:maxdepth: 3
10-
11-
api
125
136
========
147
Tibia.py
158
========
169

1710

18-
Tibia.py is a library for parsing HTML content from Tibia.com_. into python objects.
19-
20-
This library only performs parsing, to fetch content you need to use external libraries.
21-
22-
.. code-block:: python
23-
24-
import aiohttp
25-
import requests
26-
import tibiapy
27-
28-
# Asynchronously
29-
async def get_character(name):
30-
url = tibiapy.Character.get_url(name)
31-
32-
try:
33-
async with aiohttp.ClientSession() as session:
34-
async with session.get(url) as resp:
35-
content = await resp.text()
36-
character = tibiapy.Character.from_content(content)
37-
return character
11+
Tibia.py is a library for parsing HTML content from Tibia.com_. into Python objects.
12+
It can also parse json content from TibiaData_.
3813

39-
# Synchronously
40-
def get_character_sync(name):
41-
url = tibiapy.Character.get_url(name)
42-
43-
r = requests.get(url)
44-
content = r.text()
45-
character = tibiapy.Character.from_content(content)
46-
return character
14+
**Features:**
4715

16+
- Converts data into well-structured Python objects.
17+
- Type consistent attributes.
18+
- All objects can be converted to JSON strings.
19+
- Can be used with any networking library.
20+
- Support for characters, guilds, houses and worlds.
4821

4922

5023
.. _Tibia.com: https://www.tibia.com/news/?subtopic=latestnews
51-
52-
53-
24+
.. _TibiaData: https://www.tibiadata.com/
5425

5526

5627
Indices and tables
5728
==================
5829

30+
.. toctree::
31+
:maxdepth: 3
32+
33+
intro
34+
api
35+
5936
* :ref:`genindex`
6037
* :ref:`search`
6138

docs/intro.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
============
2+
Introduction
3+
============
4+
5+
Prerequisites
6+
=============
7+
Tibia.py requires Python 3.5 or higher.
8+
Dependencies are installed automatically when installing the package.
9+
10+
However, since it uses ``lxml`` for parsing, on Linux you may require to install libxml on your system.
11+
12+
13+
.. code-block:: shell
14+
15+
sudo apt-get install libxml2-dev libxslt-dev python-dev
16+
17+
Windows users are usually safe from this. For more information check out `lxml installation page`_
18+
.
19+
20+
21+
22+
Installation
23+
============
24+
Tibia.py can be installed from `PyPi`_ using:
25+
26+
.. code-block:: shell
27+
28+
python -m pip install tibia.py
29+
30+
.. _lxml installation page: https://lxml.de/installation.html
31+
.. _PyPi: https://pypi.org/
32+
33+
Usage
34+
=====
35+
This library only performs parsing, to fetch content you need to use external libraries.
36+
37+
The main models have a ``get_url``/``get_url_tibiadata`` method that can be used to get their Tibia.com/TibiaData.com page.
38+
With the url, the html/json content can be fetched and then passed to their ``from_content``/``from_tibiadata`` methods.
39+
40+
.. code-block:: python
41+
42+
import aiohttp
43+
import requests
44+
import tibiapy
45+
46+
# Asynchronously
47+
async def get_character(name):
48+
url = tibiapy.Character.get_url(name)
49+
50+
try:
51+
async with aiohttp.ClientSession() as session:
52+
async with session.get(url) as resp:
53+
content = await resp.text()
54+
character = tibiapy.Character.from_content(content)
55+
return character
56+
57+
# Synchronously
58+
def get_character_sync(name):
59+
url = tibiapy.Character.get_url(name)
60+
61+
r = requests.get(url)
62+
content = r.text
63+
character = tibiapy.Character.from_content(content)
64+
return character

0 commit comments

Comments
 (0)