Skip to content

Commit a3efda7

Browse files
committed
Merge branch 'documentation-unstable' into documentation
2 parents 2f2a871 + 2ceb2ce commit a3efda7

File tree

13 files changed

+1497
-833
lines changed

13 files changed

+1497
-833
lines changed

.pylintrc

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.

README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
README
1+
AWSW-Modtools
22
======
33

4-
Please click `this link`_ or see the current documentation inside the docs/ folder.
4+
AWSW-Modtools is a modding framework for the visual novel _Angels with Scaly Wings_.
5+
The goal is to have an easy-to-use modding framework that loads mods and allows mods to expand the game.
6+
7+
Please check out the `installation guide`_ on how to install the modding framework.
8+
If you'd like to make your own mods or to contribute to the modding effort, please click `this link`_ or see the current documentation inside the docs/ folder.
59

610
.. _this link: https://scrlys.github.io/AWSW-Modtools/

docs/API.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
modlib
1+
API
22
------
33

4-
.. automodule:: modloader.modlib
4+
.. automodule:: modloader.modgame
5+
:members:
6+
7+
.. automodule:: modloader.modast
58
:members:

docs/documentation.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@ Documenting the code, especially the API, is critical to ensure that the modding
66
Style Guide
77
-----------
88

9-
All the Python code must follow `PEP 8`_. The docstrings must follow `Google's style guide`_.
9+
All the Python code must follow `PEP 8`_. The docstrings must follow Napoleon, Google's docstring style. You can find more information in `Google's style guide`_ and `Sphinx documentation`_
10+
Before merging into any major branch, ensure that pylint returns no problems.
11+
12+
To execute pylint under a Unix environment:
13+
14+
* Install normally through Python 2's pip
15+
* Enter the game/ folder in the installation directory
16+
* Run ``pylint modloader``
17+
18+
To run pylint for mods, run ``pylint mods/modname`` where modname is the mod's name.
1019

1120
.. _PEP 8: https://www.python.org/dev/peps/pep-0008/
1221
.. _Google's style guide: https://google.github.io/styleguide/pyguide.html#Comments
22+
.. _Sphinx documentation: http://www.sphinx-doc.org/en/stable/ext/napoleon.html
1323

1424
Building Documentation
1525
----------------------

modloader/__init__.py

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,73 @@
1-
import renpy
1+
"""This file is free software under the GPLv3 license."""
2+
23
import os
34
import sys
4-
import modinfo
55
import importlib
6-
import modinfo
7-
import modclass
6+
import renpy
7+
from modloader import modinfo, modclass
8+
9+
print 'AWSW Mod Loader Init'
810

9-
print('AWSW Mod Loader Init')
1011

1112
def get_mod_path():
1213
"""Get the mod path
1314
1415
Returns:
1516
The full path to the mods folder
1617
"""
17-
#TODO: Use a path combining function
18-
return renpy.config.gamedir + "/mods/"
18+
return os.path.join(renpy.config.gamedir, "mods")
19+
1920

2021
def main():
21-
# By setting the import path to the mod folder, we can do something like `import mod`
22-
# NOTE: To import files in the modloader/ folder, do `from modloader import ...`
23-
# If we add the modloader to the path, the modlist would get reloaded again
22+
"""Load the mods"""
23+
# By appending the mod folder to the import path we can do something like
24+
# `import test` to import the mod named test in the mod folder.
2425
sys.path.append(get_mod_path())
26+
# NOTE: To import files in the modloader/ folder, do
27+
# `from modloader import ...`. If we add the modloader to the path,
28+
# the modules would be reimported every time they are imported.
29+
# In most cases, that's fine, but when modinfo is reimported, we lose the
30+
# current list of mods.
2531

2632
for mod in os.listdir(get_mod_path()):
27-
# Some mods require resources to be recognized by renpy. If a folder exists, force renpy to load it
28-
resource_dir = get_mod_path() + mod + "/resource"
33+
# Some mods require resources to be recognized by renpy.
34+
# If a folder exists, force renpy to load it
35+
resource_dir = os.path.join(get_mod_path(), mod, 'resource')
2936
if os.path.isdir(resource_dir):
3037
renpy.config.searchpath.append(resource_dir)
3138

32-
# Try importing the mod. If all goes well, the mod is imported through the Mod class
33-
print("Begin mod load: {}".format(mod))
39+
print "Begin mod load: {}".format(mod)
3440

41+
# Try importing the mod.
42+
# Note: This doesn't give my mod functionality. To give the mod
43+
# function, make a Mod class and apply the loadable_mod decorator
3544
mod_object = importlib.import_module(mod)
3645

37-
# Run through registry to see if the mod implements loadable_mod in some way.
38-
if not any(modinfo.get_mods()[key][4] == mod_object for key in modinfo.get_mods()):
39-
modinfo.add_mod(mod_object.__name__, (None, "", "", "", mod_object))
46+
# Put the mod into the registry if it doesn't already exist
47+
# This is for legacy detection of the previous mod importation system
48+
# Avoid using this as it might get removed in later commits
49+
mods = modinfo.get_mods()
50+
if not any(mods[key][4] == mod_object for key in mods):
51+
info = (None, "", "", "", mod_object)
52+
modinfo.add_mod(mod_object.__name__, info)
4053

41-
# After all ods are loaded, call their respective mod_complete functions
54+
# After all mods are loaded, call their respective mod_complete functions
4255
for mod_name, mod_data in modinfo.get_mods().iteritems():
4356
if mod_data[0]:
44-
print("Completing mod {}".format(mod_name))
57+
print "Completing mod {}".format(mod_name)
4558
mod_data[0].mod_complete()
4659

47-
# force renpy to reindex all game files
60+
# Force renpy to reindex all game files
4861
renpy.loader.old_config_archives = None
4962

50-
# Ensure that we have a stable renpy environment.
51-
# The documentation won't have a stable renpy.config.gamedir, but the game will
63+
# When we build the documentation, renpy.config.gamedir will not exist
64+
# However, when the game is ran, it will exist. We take abuse of that
5265

5366
try:
54-
renpy.config.gamedir
55-
building_documentation = False
67+
_ = renpy.config.gamedir
68+
BUILDING_DOCUMENTATION = False
69+
except AttributeError:
70+
BUILDING_DOCUMENTATION = True
71+
72+
if not BUILDING_DOCUMENTATION:
5673
main()
57-
except:
58-
building_documentation = True

0 commit comments

Comments
 (0)