Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AWhetter committed Sep 30, 2023
1 parent 1e4c9bc commit e6c4d42
Show file tree
Hide file tree
Showing 107 changed files with 3,678 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: tests

on:
- push
- pull_request

jobs:
test:
strategy:
matrix:
# Keep this in sync with tox.ini
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions
- name: Run tests
run: tox
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on: push

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/autogqlschema
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v1.2.3
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.egg-info
*.pyc
.mypy_cache/
.pytest_cache/
.ruff_cache/
.tox/
_build
build/
dist/
__pycache__/
13 changes: 13 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
install:
- method: pip
path: .
extra_requirements:
- doc
Empty file added CHANGELOG.rst
Empty file.
26 changes: 26 additions & 0 deletions LICENSE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
The MIT License (MIT)
=====================

Copyright (c) 2023 Ashley Whetter

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

146 changes: 146 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
autogqlschema
==============

.. image:: https://readthedocs.org/projects/autogqlschema/badge/?version=latest
:target: https://autogqlschema.readthedocs.org
:alt: Documentation

.. image:: https://github.com/AWhetter/autogqlschema/actions/workflows/main.yml/badge.svg?branch=main
:target: https://github.com/AWhetter/autogqlschema/actions/workflows/main.yml?query=branch%3Amain
:alt: Github Build Status

.. image:: https://img.shields.io/pypi/v/autogqlschema.svg
:target: https://pypi.org/project/autogqlschema/
:alt: PyPI Version

.. image:: https://img.shields.io/pypi/pyversions/autogqlschema.svg
:target: https://pypi.org/project/autogqlschema/
:alt: Supported Python Versions

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
:alt: Formatted with Black

A Sphinx extension for automatically documenting GraphQL schemas.


Getting Started
---------------

The following steps will walk through how to add ``autogqlschema`` to an existing Sphinx project.
For instructions on how to set up a Sphinx project,
see Sphinx's documentation on
`Getting Started <https://www.sphinx-doc.org/en/master/usage/quickstart.html>`_.


Installation
~~~~~~~~~~~~

``autogqlschema`` can be installed through pip:

.. code-block:: bash
pip install autogqlschema
Next, add ``autogqlschema`` to the ``extensions`` list in your Sphinx project's `conf.py`.

.. code-block:: python
extensions.append("autogqlschema")
Usage
-----

Schema documentation is generated from GraphQL schema files using the ``autogqlschema`` directive.

In the following example, documentation is generated from ths file structure.

.. code-block:: none
myrepo
├── doc
├── conf.py
└── index.rst
└── src
└── mypackage
├── schema
│ ├── __init__.py
│ ├── 01_schema.graphql
│ └── 02_books.graphql
└── __init__.py
This schema can be generated with the following reStructuredText:

.. code-block:: rst
.. autogqlschema::
:root-dir: ../src/mypackage/schema
:source-files: *.graphql
Or:

.. code-block:: rst
.. autogqlschema::
:root-dir: ../src/mypackage/schema
:source-files: 01_schema.graphql, 02_books.graphql
For more detailed usage, see the documentation:
https://autogqlschema.readthedocs.io/en/latest/


Contributing
------------

Running the tests
~~~~~~~~~~~~~~~~~

Tests are executed through `tox <https://tox.readthedocs.io/en/latest/>`_.

.. code-block:: bash
tox
Code Style
~~~~~~~~~~

Code is formatted using `black <https://github.com/python/black>`_.

You can check your formatting using black's check mode:

.. code-block:: bash
tox -e format
You can also get black to format your changes for you:

.. code-block:: bash
tox -e format -- src/ tests/
Release Notes
~~~~~~~~~~~~~

Release notes are managed through `towncrier <https://towncrier.readthedocs.io/en/stable/index.html>`_.
When making a pull request you will need to create a news fragment to document your change:

.. code-block:: bash
tox -e release_notes -- create --help
Versioning
----------

We use `SemVer <https://semver.org/>`_ for versioning.
For the versions available, see the `tags on this repository <https://github.com/AWhetter/autogqlschema/tags>`_.


License
-------

This project is licensed under the MIT License.
See the `LICENSE.rst <LICENSE.rst>`_ file for details.
Empty file added doc/changes/.gitkeep
Empty file.
Empty file added doc/source/_static/.gitkeep
Empty file.
48 changes: 48 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'autogqlschema'
copyright = '2023, Ashley Whetter'
author = 'Ashley Whetter'
release = '0.1.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'autogqlschema',
'sphinx.ext.intersphinx',
]

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']


# -- Options for intersphinx -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#configuration

intersphinx_mapping = {
'sphinx': ('https://www.sphinx-doc.org/en/master', None),
}


def setup(app):
app.add_object_type(
'confval',
'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value',
)
Loading

0 comments on commit e6c4d42

Please sign in to comment.