Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types, docs, linting #1

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Linting
on: [push]

jobs:
build:
lint:

runs-on: ubuntu-latest

Expand Down
26 changes: 26 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.8"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt

53 changes: 0 additions & 53 deletions README.md

This file was deleted.

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

Yarnbot is a Slack-bot that knows some yarn-working things, and can search
Ravelry for patterns, yarn, or user favorites.


Yarnbot understands:

* <7 character abbreviations
* Yarn weights
* Needle/Hook sizes (say 'US 10', '5mm', 'Crochet L', etc)
* Basic arithmetic expressions
* **weights**: List all yarn weights
* **ravelry favorites** <Ravelry Username>
* **ravelry favorites** <Ravelry Username> **tagged** <tag>
* **ravelry search** <search terms>: Search patterns
* **ravelry yarn** <search terms>: Search yarn
* **ravelry yarn similar to** <search terms>: Find similar yarn
* **info**: Yarnbot info
* **help**: Help text

Running
-------

Before anything else will work, you will need to create a bot in Slack. In your team's app management section, create a custom integration and add a bot configuration. The API Token available there is the ``SLACK_API_KEY`` referenced below.

Use a script such as the provded example to set the various access keys and run the client. It will try to stay connected to slack until you tell it to ``go to sleep``, which will cause it to disconnect gracefully.

Yarnbot will create a log file named ``yarnbot.log`` in the current directory. By default, it logs at the INFO level, but that can be changed by altering the logging setup at the beginning of ``yarnbot.py``.

As it runs, it keeps track of users it has seen, and saves them in ``known_users.pkl``. Please note that is a python pickle file.

Access Tokens
^^^^^^^^^^^^^

Yarnbot requires a Slack API key, taken from the ``SLACK_API_KEY`` environment variable, as well as Ravelry OAuth1 keys, taken from ``RAV_ACC_KEY`` and ``RAV_SEC_KEY``.

Screenshots
-----------

Some typical yarnbot commands

.. image:: https://imgur.com/1cPZXV1.png
:alt: yarnbot commands

Ravelry search results show short summaries of each pattern. Clicking the pattern will take you to Ravelry to see details.

.. image:: https://imgur.com/hx5Yo7x.png
:alt: yarnbot ravelry search

You can also search for yarn...

.. image:: https://imgur.com/efIld1B.png
:alt: yarnbot ravelry yarn

...and find similar yarn.

.. image:: https://imgur.com/gfA9aOC.png
:alt: yarnbot ravelry yarn similar to

20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13 changes: 13 additions & 0 deletions docs/_static/patch.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dl:not(.docutils) dt{
background:rgba(51, 195, 240, 0.1);
color:rgba(0, 174, 228, 0.9);
}

a {
color: #00aee4;
}


.c-primary{
color:#00aee4;
}
96 changes: 96 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, '..')
from yarnbot import __version__

# -- Project information -----------------------------------------------------

project = 'yarnbot'
copyright = '2022, Nigel Stepp'
author = 'Nigel Stepp'

# The short X.Y version
version = __version__

# The full version, including alpha/beta/rc tags
release = __version__


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.todo',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'karma_sphinx_theme'
#import sphinx_readable_theme
#html_theme = 'readable'
#html_theme_path = [sphinx_readable_theme.get_html_theme_path()]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Extension configuration -------------------------------------------------

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}

# -- Options for todo extension ----------------------------------------------

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

autodoc_mock_imports = ['slack_bolt']

def setup(app):
app.add_css_file('patch.css')

22 changes: 22 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. yarnbot documentation master file, created by
sphinx-quickstart on Sun Apr 3 01:16:59 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to yarnbot's documentation!
===================================

.. toctree::
:maxdepth: 4
:caption: Contents:

yarnbot

.. include:: ../README.rst

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests
slack-bolt
karma-sphinx-theme
7 changes: 7 additions & 0 deletions docs/yarnbot.app.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
yarnbot.app
===========

.. automodule:: yarnbot.app
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/yarnbot.conversations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
yarnbot.conversations
=====================

.. automodule:: yarnbot.conversations
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/yarnbot.data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
yarnbot.data
============

.. automodule:: yarnbot.data
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/yarnbot.ravelry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
yarnbot.ravelry
===============

.. automodule:: yarnbot.ravelry
:members:
:undoc-members:
:show-inheritance:
19 changes: 19 additions & 0 deletions docs/yarnbot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
yarnbot
=======

.. automodule:: yarnbot
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

yarnbot.app
yarnbot.conversations
yarnbot.data
yarnbot.ravelry
yarnbot.state
Loading