Merge pull request #27 from nabobalis/master

support for circeci, updated Travis CI, added notebook example
This commit is contained in:
Nabil Freij 2018-10-27 21:08:59 +01:00 committed by GitHub
commit 2794f521ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 223 additions and 43 deletions

77
.circleci/config.yml Normal file
View file

@ -0,0 +1,77 @@
apt-run: &apt-install
name: Install apt packages
command: |
apt update
apt install -y graphviz build-essential
docs-install: &docs-install
name: Install Python dependencies
command: |
pip install werkzeug sphinx alabaster invoke python-dateutil sphinx-automodapi nbsphinx ipython
version: 2
jobs:
egg-info-27:
docker:
- image: circleci/python:2.7
steps:
- checkout
- run: python setup.py egg_info
egg-info-35:
docker:
- image: circleci/python:3.5
steps:
- checkout
- run: python setup.py egg_info
egg-info-36:
docker:
- image: circleci/python:3.6
steps:
- checkout
- run: python setup.py egg_info
egg-info-37:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run: python setup.py egg_info
html-docs:
docker:
- image: continuumio/miniconda3
steps:
- checkout
- run: *skip-check
- run: *apt-install
- run: *docs-install
- run: python setup.py build_sphinx -w
- store_artifacts:
path: build/sphinx/html/index.html
- run:
name: "Built documentation is available at:"
command: DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/build/sphinx/html/index.html"; echo $DOCS_URL
workflows:
version: 2
egg-info:
jobs:
- egg-info-27
- egg-info-35
- egg-info-36
- egg-info-37
documentation:
jobs:
- html-docs
notify:
webhooks:
- url: https://giles.cadair.com/circleci

View file

@ -1 +0,0 @@
repo_token: niCbipldEa8bIbuYwWyJqo7082UOtku0w

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
MANIFEST
docs/manual/.ipynb_checkpoints/*
# Distribution / packaging
build/

View file

@ -2,8 +2,5 @@ pycodestyle:
max-line-length: 120 # Default is 79 in PEP8
exclude:
- setup.py
- ez_setup.py
- ah_bootstrap.py
- astropy_helpers/
- docs/conf.py
descending_issues_order: True

View file

@ -8,3 +8,5 @@ dependencies:
- invoke
- python-dateutil
- sphinx-automodapi
- nbsphinx
- ipython

View file

@ -12,26 +12,28 @@ sudo: false
env:
matrix:
- PYTHON_VERSION=2.7 SPHINX_VERSION=1.6
- PYTHON_VERSION=2.7
- PYTHON_VERSION=2.7 SPHINX_VERSION=1.8
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.6
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.8
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.6
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.6 SPHINX_VERSION=dev
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.8
- PYTHON_VERSION=3.7 SPHINX_VERSION=1.6
- PYTHON_VERSION=3.7 SPHINX_VERSION=1.7
- PYTHON_VERSION=3.7 SPHINX_VERSION=1.8
global:
- LOCALE=default
- CONDA_CHANNELS="conda-forge"
- CONDA_DEPENDENCIES="sphinx werkzeug alabaster invoke graphviz"
- CONDA_DEPENDENCIES="sphinx werkzeug alabaster invoke graphviz nbsphinx"
- PIP_DEPENDENCIES="sphinx-automodapi"
install:
- git clone git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- if [[ $SPHINX_VERSION == dev ]]; then
pip install git+https://github.com/sphinx-doc/sphinx.git;
fi
- pip install -e .
script:
- make test
- make tests

View file

@ -1,26 +1,28 @@
.PHONY: demo install rebuild release test docs
.PHONY: demo rebuild tests
demo:
rm -rf demo
printf "demo\nABlog\nABlog Team\nhttp://ablog.readthedocs.org" | ablog start
install:
pip install -U --no-deps --force-reinstall .
docs:
export PYTHONPATH="$(shell pwd)"; echo $$PYTHONPATH; cd docs; ablog build -a -P
rebuild:
cd docs; watchmedo shell-command --patterns='*.rst' --command='ablog build' --recursive
release:
python setup.py register
python setup.py sdist upload
test:
cd docs; ablog build -T
test1:
cd docs; ablog build -b latex -T -d .doctrees -w _latex
test2:
cd docs; ablog build -T -b json
test3:
cd docs; ablog build -T -b pickle
test4:
mkdir -p test; cd test; printf "\nABlog\nABlog Team\nhttp://ablog.readthedocs.org" | ablog start; ablog build
test5:
mkdir -p test; cd test; printf "ablog\nABlog\nABlog Team\nhttp://ablog.readthedocs.org" | ablog start; cd ablog; ablog build
tests: test test1 test2 test3 test4 test5

View file

@ -3,7 +3,7 @@ ABlog for Sphinx
.. image:: https://travis-ci.org/sunpy/ablog.svg?branch=master
:target: https://travis-ci.org/sunpy/ablog
**Please note that is an official continuation of** `Ahmet Bakan's Ablog Sphinx extension <https://github.com/abakan/ablog/>`_.
ABlog is a Sphinx extension that converts any documentation or personal website project into a full-fledged blog with:
@ -14,6 +14,7 @@ ABlog is a Sphinx extension that converts any documentation or personal website
* `Disqus integration`_
* `Font-Awesome integration`_
* `Easy GitHub Pages deploys`_
* `Jupiter Notebook Support for blog posts`_
.. _Atom feeds: http://ablog.readthedocs.org/blog/atom.xml
.. _Archive pages: http://ablog.readthedocs.org/blog/
@ -21,6 +22,7 @@ ABlog is a Sphinx extension that converts any documentation or personal website
.. _Disqus integration: http://ablog.readthedocs.org/manual/ablog-configuration-options/#disqus-integration
.. _Font-Awesome integration: http://ablog.readthedocs.org/manual/ablog-configuration-options/#fa
.. _Easy GitHub Pages deploys: http://ablog.readthedocs.org/manual/deploy-to-github-pages/
.. _Jupiter Notebook Support for blog posts: http://ablog.readthedocs.org/manual/notebook_support/
.. _installation:
@ -31,9 +33,14 @@ You can install ABlog using pip_::
pip install -U ablog
or anaconda_::
conda config --add channels conda-forge
conda install ablog
This will also install `Sphinx <http://sphinx-doc.org/>`_, Alabaster_, Werkzeug_, and Invoke_ respectively required for building your website, making it look good, generating feeds, and running deploy commands.
.. _pip: https://pip.pypa.io
.. _anaconda: https://www.anaconda.com/
.. _Werkzeug: http://werkzeug.pocoo.org/
.. _Alabaster: https://github.com/bitprophet/alabaster
.. _Invoke: http://www.pyinvoke.org/

View file

@ -1,5 +1,6 @@
from __future__ import absolute_import, division, print_function
import os
import io
import sys
import glob
import ablog
@ -175,11 +176,11 @@ def ablog_build(builder=None, sourcedir=None, website=None, doctrees=None,
argv.extend([sourcedir, website])
if SPHINX_LT_17:
from sphinx import main
main(argv)
sys.exit(main(argv))
else:
from sphinx.cmd.build import main
# As of Sphinx 1.7, the first argument is now no longer ignored
main(argv[1:])
sys.exit(main(argv[1:]))
@arg('-D', dest='deep', action='store_true', default=False,
@ -331,7 +332,7 @@ def ablog_post(filename, title=None, **kwargs):
# read the file, and add post directive
# and save it
else:
with open(filename, 'w', encoding='utf-8') as out:
with io.open(filename, 'w', encoding='utf-8') as out:
post_text = POST_TEMPLATE % pars
out.write(post_text)

View file

@ -2,6 +2,7 @@
"""post and postlist directives."""
from __future__ import absolute_import, division, print_function
import io
import os
import sys
from string import Formatter
@ -655,7 +656,7 @@ def generate_atom_feeds(app):
if not os.path.isdir(parent_dir):
os.makedirs(parent_dir)
with open(feed_path, 'w', encoding='utf-8') as out:
with io.open(feed_path, 'w', encoding='utf-8') as out:
feed_str = feed.to_string()
try:
out.write(feed_str.encode('utf-8'))

View file

@ -11,13 +11,14 @@ environment:
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
CONDA_CHANNELS: "conda-forge"
CONDA_DEPENDENCIES: "sphinx werkzeug alabaster invoke graphviz"
CONDA_DEPENDENCIES: "sphinx werkzeug alabaster invoke graphviz nbsphinx"
PIP_DEPENDENCIES: "sphinx-automodapi"
matrix:
- PYTHON_VERSION: "2.7"
- PYTHON_VERSION: "3.5"
- PYTHON_VERSION: "3.6"
- PYTHON_VERSION: "3.7"
matrix:
fast_finish: true
@ -25,6 +26,11 @@ matrix:
platform:
- x64
before_test:
- cinst pandoc
- cinst graphviz
- set PATH="%PATH%;C:\Program Files (x86)\Pandoc\"
install:
- "git clone git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
@ -41,12 +47,3 @@ test_script:
- ablog build -b latex -T -d .doctrees -w _latex
- ablog build -T -b json
- ablog build -T -b pickle
# - ps: mkdir test
# - ps: cd test
# - ps: echo "ABlog" ABlog Team" "http://ablog.readthedocs.org" | ablog start
# - ablog build
# - ps: mkdir -p test
# - ps: cd test
# - ps: echo "ablog" "ABlog" "ABlog Team" "http://ablog.readthedocs.org" | ablog start
# - ps: cd ablog
# - ablog build

View file

@ -19,6 +19,7 @@ extensions = [
'sphinx.ext.extlinks',
'sphinx_automodapi.automodapi',
'alabaster',
'nbsphinx',
'ablog'
]
@ -106,6 +107,8 @@ extlinks = {
'pull': ('https://github.com/sunpy/ablog/pull/%s', 'pull request '),
}
exclude_patterns = ['docs/manual/.ipynb_checkpoints/*']
rst_epilog = '''
.. _Sphinx: http://sphinx-doc.org/
.. _Python: http://python.org

View file

@ -73,6 +73,8 @@ you might find `reStructuredText Primer`_ useful. Once you have
content (in ``.rst`` files), you can post *any page* using the
:rst:dir:`post` directive as follows:
.. _reStructuredText Primer: http://sphinx-doc.org/rest.html
.. code-block:: rst
.. post:: Apr 15, 2014
@ -104,10 +106,6 @@ can find more about configuring and using ABlog:
:format: {title}
:sort:
.. _reStructuredText Primer: http://sphinx-doc.org/rest.html
.. only:: html
.. image:: https://secure.travis-ci.org/sunpy/ablog.png?branch=devel

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jupyter Notebook Posting"
]
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
".. post:: 27 Oct 2018\n",
" :author: Nabil\n",
" :tags: posting\n",
" :category: Manual"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To add support for Notebooks to your Ablog instance, you need to configure your `docs/conf.py` (or whereever your `conf.py` is located.\n",
"\n",
"You will need to add\n",
"\n",
"```\n",
" extennsions = [..., 'nbsphinx', ...]\n",
" exclude_patterns = ['docs/manual/.ipynb_checkpoints/*'] (To exclude the notebook autosaves)\n",
"```\n",
"\n",
"You will need to install [nbsphinx](https://nbsphinx.readthedocs.io/) either from `Anaconda` or `pip`. You might need to install [ipython](https://ipython.org/) to make sure the notebook can be run."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Within the notebook you need to make sure the cells are in this order: Titlte cell, post cell. So for this notebook, it looks like this: ![posting](images/notebook_cells.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So the information is similar to how you create a normal RST post."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another working example is SunPy's website which runs [Ablog](https://sunpy.org/blog.html). The Pull Request that added support can be found [here](https://github.com/sunpy/sunpy.org/pull/131) and how to link them to a [Binder](https://mybinder.org/) instance [here](https://github.com/sunpy/sunpy.org/pull/134)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View file

@ -50,3 +50,14 @@ ABlog v0.9.2 released
:location: World
Fixed Windows String issue
ABlog v0.9.3 released
=====================
.. post:: October 30, 2018
:author: Nabil
:category: Release
:location: World
Added example on how to use writing blog posts in Jupyter notebooks.
Several fixes provived by `anzawatta`, sorry I was late to release these!

View file

@ -53,6 +53,7 @@ setup(
],
provides=['ablog'],
install_requires=['werkzeug', 'sphinx>=1.6', 'alabaster', 'invoke', 'python-dateutil', 'sphinx-automodapi'],
extra_requires=['nbsphinx'],
message_extractors={
'ablog': [
('**.html', 'jinja2', None),