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

Sphinx Integration for Python Utilities #2

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
embed code instructions for markdown files
franklinselva committed Nov 9, 2022
commit b85e20f7033556cb6a4c3f3afb61893779484a40
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ This is a walkthrough of the SPHINX workflow. It is intended to be a quick refer

## Setup

1. The workflow is divided into 3 steps:
The workflow is divided into 3 steps:

1. Generate Markdowns for the python directory

```bash

@@ -16,10 +18,13 @@ bash scripts/generate_markdown.sh doc/pages
2. To embed the code into markdown files, run the following command:

```bash
# TODO: Add the command to embed the code
npm i -g markdown-autodocs
markdown-autodocs -c code-block -o doc/pages/*
```

3. To setup sphinx, run the following commands:
The package is also available as github action. The action can be found [here](https://github.com/marketplace/actions/markdown-autodocs).

3. To setup sphinx, run the following commands:

```bash
# In Ubuntu 20.04
86 changes: 78 additions & 8 deletions doc/pages/2fa.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,95 @@
# 2fa

## authy user qr show
```python
/2fa/authy-user-qr-show.py

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../python/2fa/authy-user-qr-show.py) -->
<!-- The below code snippet is automatically added from ../../python/2fa/authy-user-qr-show.py -->
```py
import sys
import os
from authy.api import AuthyApiClient

authy_api = AuthyApiClient(os.environ.get("AUTHY_API_KEY"))

# Available in version 2.2.4+
response = authy_api.users.generate_qr(os.environ.get("AUTHY_USER_ID"), size=200, label="QR for cherkavi-test")
if response.ok():
print(response.content['qr_code'])
else:
print(response.content["message"])
```
<!-- MARKDOWN-AUTO-DOCS:END -->



## authy user register
```python
/2fa/authy-user-register.py

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../python/2fa/authy-user-register.py) -->
<!-- The below code snippet is automatically added from ../../python/2fa/authy-user-register.py -->
```py
import os
import sys
from authy.api import AuthyApiClient

# Your API key from twilio.com/console/authy/applications
# DANGER! This is insecure. See http://twil.io/secure
authy_api = AuthyApiClient(os.environ.get("AUTHY_API_KEY"))

email = sys.argv[1] # 'some_email@gmail.com'
phone = sys.argv[2] # '135 35 35 35 35'
# https://github.com/twilio/authy-form-helpers/blob/master/src/form.authy.js
country_code = sys.argv[3] # 49

user = authy_api.users.create(email=email,phone=phone,country_code=country_code)
if user.ok():
print(user.id) # user.id is the `authy_id` needed for future requests
else:
print(user.errors())
```
<!-- MARKDOWN-AUTO-DOCS:END -->



## authy user status
```python
/2fa/authy-user-status.py

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../python/2fa/authy-user-status.py) -->
<!-- The below code snippet is automatically added from ../../python/2fa/authy-user-status.py -->
```py
from authy.api import AuthyApiClient
import pprint
import os

# check client status
authy_api = AuthyApiClient(os.environ.get("AUTHY_API_KEY"))
status = authy_api.users.status(os.environ.get("AUTHY_USER_ID"))
if status.ok():
print("OK")
else:
print("---ERROR---")
pprint.PrettyPrinter(indent=4).pprint(status)
```
<!-- MARKDOWN-AUTO-DOCS:END -->



## authy user verify
```python
/2fa/authy-user-verify.py

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../python/2fa/authy-user-verify.py) -->
<!-- The below code snippet is automatically added from ../../python/2fa/authy-user-verify.py -->
```py
import sys
import os
from authy.api import AuthyApiClient

authy_api = AuthyApiClient(os.environ.get("AUTHY_API_KEY"))
# sms = authy_api.users.request_sms(current_user.authy_id, {'force': True})
# verification = authy_api.phones.verification_check("13535353535","49", sys.argv[1])
verification = authy_api.tokens.verify(token = sys.argv[1], device_id=os.environ.get("AUTHY_USER_ID"))
if verification.ok():
print("OK")
else:
print("error")
```
<!-- MARKDOWN-AUTO-DOCS:END -->


Loading