diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0035810 --- /dev/null +++ b/.circleci/config.yml @@ -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 \ No newline at end of file diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index da424c2..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -repo_token: niCbipldEa8bIbuYwWyJqo7082UOtku0w diff --git a/.gitignore b/.gitignore index 9bd1819..bc15156 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__/ *.py[cod] MANIFEST +docs/manual/.ipynb_checkpoints/* # Distribution / packaging build/ diff --git a/.pep8speaks.yml b/.pep8speaks.yml index 6b61688..c6c20d2 100644 --- a/.pep8speaks.yml +++ b/.pep8speaks.yml @@ -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 diff --git a/.rtd-environment.yml b/.rtd-environment.yml index 9979374..6e5cb2e 100644 --- a/.rtd-environment.yml +++ b/.rtd-environment.yml @@ -8,3 +8,5 @@ dependencies: - invoke - python-dateutil - sphinx-automodapi +- nbsphinx +- ipython \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4b8a840..b0e26f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index c5efb1c..063b608 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.rst b/README.rst index 1bae24d..14fd142 100644 --- a/README.rst +++ b/README.rst @@ -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 `_. 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 `_, 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/ diff --git a/ablog/commands.py b/ablog/commands.py index ad16b18..ed48e9c 100644 --- a/ablog/commands.py +++ b/ablog/commands.py @@ -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) diff --git a/ablog/post.py b/ablog/post.py index 0b8d01b..fbf9998 100644 --- a/ablog/post.py +++ b/ablog/post.py @@ -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')) diff --git a/appveyor.yml b/appveyor.yml index b6e783e..8b13767 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 4058a9e..b92a7c8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 diff --git a/docs/index.rst b/docs/index.rst index 357e9c9..9313e5b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 diff --git a/docs/manual/images/notebook_cells.png b/docs/manual/images/notebook_cells.png new file mode 100644 index 0000000..1411a86 Binary files /dev/null and b/docs/manual/images/notebook_cells.png differ diff --git a/docs/manual/notebook_support.ipynb b/docs/manual/notebook_support.ipynb new file mode 100644 index 0000000..8f1b483 --- /dev/null +++ b/docs/manual/notebook_support.ipynb @@ -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 +} diff --git a/docs/release/ablog-v0.9-released.rst b/docs/release/ablog-v0.9-released.rst index 172a528..e500442 100644 --- a/docs/release/ablog-v0.9-released.rst +++ b/docs/release/ablog-v0.9-released.rst @@ -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! \ No newline at end of file diff --git a/setup.py b/setup.py index 90417f0..db14fb5 100644 --- a/setup.py +++ b/setup.py @@ -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),