Skip to content

Commit

Permalink
tags doc init
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Oct 16, 2023
1 parent 5dd5070 commit 1e5dada
Show file tree
Hide file tree
Showing 11 changed files with 628 additions and 0 deletions.
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)
70 changes: 70 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import os
import sys

sys.path.insert(0, os.path.abspath(".."))

# 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, os.path.abspath('.'))


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

project = "Seina-Cogs"
copyright = "2021, PhenoM4n4n, inthedark.org"
author = "PhenoM4n4n, inthedark.org"


# -- 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 = [
"recommonmark",
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
]

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

# 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 = "sphinx_rtd_theme"

# 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"]

intersphinx_mapping = {
"tse": ("https://tagscriptengine.readthedocs.io/en/latest/", None),
}

default_role = "any"
9 changes: 9 additions & 0 deletions docs/credits.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=======
Credits
=======

Thank you to the following users who contributed to this documentation!

* **PhenoM4n4n** ``phenom4n4n``
* **sravan** ``sravan#0001``
* **Anik** ``aniksarker_21``
63 changes: 63 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. Phen-Cogs documentation master file, created by
sphinx-quickstart on Sat Jan 9 12:47:01 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Phen-Cogs's documentation!
=====================================

.. image:: https://i.imgur.com/dIOX12K.png
:target: https://github.com/phenom4n4n/phen-cogs
:alt: Phen-Cogs

.. image:: https://discordapp.com/api/guilds/631306089366945821/widget.png?style=shield
:target: https://discord.gg/cGJ8JmX
:alt: Discord Server

.. image:: https://img.shields.io/pypi/pyversions/Red-Discordbot
:target: https://www.python.org/downloads
:alt: PyPI - Python Version

.. image:: https://img.shields.io/badge/discord-py-blue.svg
:target: https://github.com/Rapptz/discord.py
:alt: discord.py

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Code Style: Black

.. image:: https://readthedocs.org/projects/phen-cogs/badge/?version=latest
:target: https://phen-cogs.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. toctree::
:maxdepth: 2
:caption: Tags Documentation

tags/blocks
tags/tse_blocks
tags/default_variables
tags/parsing_blocks
tags/example_tags
tags/owner_guide

.. toctree::
:maxdepth: 2
:caption: SlashTags Documentation

slashtags/slashtags
slashtags/slash_arguments
slashtags/context_menus
slashtags/example_slashtags

.. toctree::
:caption: Credits

credits

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.http://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
8 changes: 8 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
beautifulsoup4
rapidfuzz
recommonmark
Red-DiscordBot
Sphinx
sphinx_rtd_theme
tabulate
AdvancedTagScriptEngine
74 changes: 74 additions & 0 deletions docs/tags/blocks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
====
Tags
====

Tags come with the ability to create powerful custom commands through the usage of tag blocks.
The basic block begins with a ``{`` and ends with an ``}``.
More advanced blocks may contain after the block declaration ``()`` to specify a parameter or a ``:`` to specify a payload.

Block Syntax
------------

``{block(parameter):payload}``

``[arg]`` = Optional

``<arg>`` = Required

Usage
-----
.. note:: ``[p]`` is your prefix.

Add a tag using the following command::

[p]tag add mytag Hello world!

Invoke the tag with your bot prefix and the tag's name as if it were a command::

[p]mytag

The bot will then respond with the stored tag content::

Hello world!

^^^^^^^^^^^^^^^^^
Default Variables
^^^^^^^^^^^^^^^^^

Tags come with built-in variable blocks you can access for more information about the invocation context.
These are:

* ``args``
* ``author`` | ``user``
* ``target`` | ``member``
* ``channel``
* ``guild`` | ``server``

You can see attributes available using these blocks in :doc:`default_variables`.

Below is an example tag that returns info related to the tag author. ::

[p]tag add authorinfo Username: **{author}**
ID: **{author(id)}**
Creation Date: **{author(created_at)}**
Bot: **{author(bot)}**

The ``args`` block can be useful for customizing tags and works well with the :ref:`Command Block`.
Simple echo command that validates if args were provided::

[p]tag add echo {if({args}==):You must provide text to echo.|{args}}

Here's a tag that uses the default variable blocks as well as the :ref:`If Block`::

[p]tag add startertag Hi, this is an example of a tag.
This tag will now invoke a ping command.
{c:ping}
{delete({args(0)}==delete)}
{embed({
"title":"The server this was invoked on was {server}.",
"description":"{if({args}==):You did not provide any arguments for this tag|The arguments provided were: `{args}`}",
"thumbnail":{"url":"{guild(icon)}"},
"author":{"name":"{author} invoked this tag.","icon_url":"{author(avatar)}"},
"color":2105893,
"footer":{"icon_url":"{author(avatar)}","text":"{target} is the target of this tag."}
})}
100 changes: 100 additions & 0 deletions docs/tags/default_variables.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.. role:: python(code)
:language: python

=================
Default Variables
=================

The following blocks will be present and accessable as defaults when running any tag.

--------------
Meta Variables
--------------

Meta variables reference meta attributes about the tag invocation.

^^^^^^^^^^
Args Block
^^^^^^^^^^

.. autoclass:: TagScriptEngine.StringAdapter

The ``{args}`` block represents the arguments passed after the tag name when invoking
a tag. If no parameter is passed, it returns all the text after the invocation name.
If an index is passed, it will split the arguments into a list by the given splitter,
and return the word at that index. The default splitter is a " ".

**Usage:** ``{args([index]):[splitter]>}``

**Payload:** splitter

**Parameter:** index

**Examples:**

In the following examples, assume the tag's name is ``argstag`` and the message
content is ``[p]argstag My dog is cute! Would you like to see a photo?``. ::

{args}
# My dog is cute! Would you like to see a photo?

{args(1)}
# My

{args(2):!}
# Would you like to see a photo?

^^^^^^^^^^
Uses Block
^^^^^^^^^^

.. autoclass:: TagScriptEngine.IntAdapter

The ``{uses}`` block returns the number of times a tag has been used.

**Usage:** ``{uses}``

**Payload:** None

**Parameter:** None

**Examples:** ::

{uses}
# 1

------------------------
Discord Object Variables
------------------------

These blocks reference Discord objects from the tag invocation context.

^^^^^^^^^^^^
Author Block
^^^^^^^^^^^^

.. autoclass:: TagScriptEngine.MemberAdapter

^^^^^^^^^^^^
Target Block
^^^^^^^^^^^^

The ``{target}`` block follows the same usage and has the same attributes as the
:ref:`Author Block`, but it defaults to the mentioned user in the tag
invocation message if any users are mentioned, or the tag author.

**Usage:** ``{target}``

**Aliases:** ``{member}``

^^^^^^^^^^^^^
Channel Block
^^^^^^^^^^^^^

.. autoclass:: TagScriptEngine.ChannelAdapter

^^^^^^^^^^^^
Server Block
^^^^^^^^^^^^

.. autoclass:: TagScriptEngine.GuildAdapter
Loading

0 comments on commit 1e5dada

Please sign in to comment.