-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn Stone into Python package with setup.py
- Loading branch information
1 parent
2b14371
commit ead9c11
Showing
6 changed files
with
140 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Stone Changelog | ||
=============== | ||
|
||
Here are the release notes for each version of Stone. | ||
|
||
Version 0.0.1 | ||
------------- | ||
|
||
* Generate HTML from Markdown | ||
* jinja2 templating is processed in HTML files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[bdist_wheel] | ||
universal=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""Setup script for Stone | ||
See: | ||
https://github.com/NeuralSandwich/stone | ||
""" | ||
|
||
# To use a consistent encoding | ||
# pylint: disable=redefined-builtin | ||
from codecs import open | ||
from os import path | ||
|
||
# Apparently you should always prefer setuptools over distutils | ||
from setuptools import setup, find_packages | ||
|
||
# pylint: disable=invalid-name | ||
here = path.abspath(path.dirname(__file__)) | ||
|
||
# Get the long description from the README file | ||
with open(path.join(here, 'README'), encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
||
setup(name='stone-site', | ||
|
||
# Versions should comply with PEP440. For a discussion on single-sourcing | ||
version='0.1a1.dev1', | ||
|
||
|
||
description='Static site generator', | ||
long_description=long_description, | ||
|
||
# The project's main homepage | ||
url='https://github.com/NeuralSandwich/stone', | ||
|
||
# Author's details | ||
author='Sean Jones', | ||
author_email='sean@half.systems', | ||
|
||
license='MIT', | ||
|
||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
classifiers=[ | ||
# How mature is this project? Common values are | ||
# 3 - Alpha | ||
# 4 - Beta | ||
# 5 - Production/Stable | ||
'Development Status :: 3 - Alpha', | ||
|
||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', | ||
], | ||
|
||
# What does this project relate to? | ||
keywords='web html markdown static content', | ||
packages=find_packages(exclude=['contrib', 'docs', 'tests']), | ||
|
||
# List run-time dependencies here. | ||
# https://packaging.python.org/en/latest/requirements.html | ||
install_requires=['jinja2', 'Markdown'], | ||
extras_require={ | ||
'dev': ['check-manifest'], | ||
'test': ['coverage'], | ||
}, | ||
entry_points={ | ||
'console_scripts': ['stone=stone.__main__:main'] | ||
} | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Entry point for Stone""" | ||
|
||
from __future__ import print_function | ||
import argparse | ||
import os | ||
|
||
from jinja2 import Environment, FileSystemLoader, select_autoescape | ||
import markdown | ||
from .stone import ConfigLoader, add_page | ||
|
||
|
||
def main(args=None): | ||
"""Entry point function for Stone""" | ||
parser = argparse.ArgumentParser(description='Static website generator') | ||
parser.add_argument("site_root", help='website root directory') | ||
|
||
subparsers = parser.add_subparsers(help='sub-command help') | ||
newpage = subparsers.add_parser( | ||
'newpage', help=('add a new page to site.json and an emtpy file')) | ||
newpage.add_argument( | ||
"--page-type", | ||
default="post", | ||
type=str, | ||
help='type of page to generate') | ||
|
||
args = parser.parse_args() | ||
sites = ConfigLoader().load(args.site_root) | ||
|
||
if hasattr(args, 'page_type'): | ||
return add_page(args, sites) | ||
else: | ||
if not os.path.isdir(args.site_root): | ||
print("[ERROR] %s is not a directory" % args.site_root) | ||
parser.print_help() | ||
return 1 | ||
|
||
markdown_renderer = markdown.Markdown( | ||
extensions=['markdown.extensions.meta']) | ||
for site in sites: | ||
env = Environment( | ||
loader=FileSystemLoader(site.templates), | ||
autoescape=select_autoescape(["html", "xml"])) | ||
|
||
site.render(markdown_renderer, env) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters