Skip to content

Commit 3a718bd

Browse files
author
Pashutan Modaresi
committed
Major refactoring
1 parent ac8aaa2 commit 3a718bd

22 files changed

Lines changed: 169 additions & 55 deletions

docs/autogen.py

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,88 @@
1717
EXCLUDE = {
1818
}
1919

20-
# For each class to document, it is possible to:
21-
# 1) Document only the class: [classA, classB, ...]
22-
# 2) Document all its methods: [classA, (classB, "*")]
23-
# 3) Choose which methods to document (methods listed as strings):
24-
# [classA, (classB, ["method1", "method2", ...]), ...]
25-
# 4) Choose which methods to document (methods listed as qualified names):
26-
# [classA, (classB, [module.classB.method1, module.classB.method2, ...]), ...]
20+
2721
PAGES = [
2822
{
29-
'page': 'fbotics.md',
23+
'page': '_templates/generic_template/generic_template.md',
24+
'classes': [
25+
fbotics.models.payloads.generic_template.GenericTemplatePayload,
26+
fbotics.models.payloads.generic_template.GenericElement,
27+
fbotics.models.payloads.generic_template.GenericDefaultAction,
28+
],
29+
},
30+
{
31+
'page': '_templates/button_template/button_template.md',
32+
'classes': [
33+
fbotics.models.payloads.button_template.ButtonTemplatePayload,
34+
],
35+
},
36+
{
37+
'page': 'send/client.md',
3038
'methods': [
3139
fbotics.Client.send_message,
3240
fbotics.Client.retrieve_supported_tags,
3341
],
3442
},
3543
{
36-
'page': 'buttons.md',
44+
'page': 'quick_replies/quick_replies.md',
45+
'classes': [
46+
fbotics.models.quick_reply.QuickReply,
47+
],
48+
},
49+
{
50+
'page': 'send/request.md',
51+
'classes': [
52+
fbotics.models.request.Request,
53+
],
54+
},
55+
{
56+
'page': 'send/recipient.md',
57+
'classes': [
58+
fbotics.models.recipient.Recipient,
59+
],
60+
},
61+
{
62+
'page': 'buttons/buttons.md',
3763
'classes': [
3864
fbotics.models.buttons.WebUrlButton,
3965
fbotics.models.buttons.CallButton,
4066
fbotics.models.buttons.PostbackButton
4167
],
4268
},
4369
{
44-
'page': 'message.md',
70+
'page': 'send/message.md',
4571
'classes': [
4672
fbotics.models.message.Message,
4773
],
4874
},
4975
{
50-
'page': 'templates.md',
76+
'page': 'send/attachment.md',
5177
'classes': [
52-
fbotics.models.payloads.button_template.ButtonTemplatePayload,
53-
fbotics.models.payloads.generic_template.GenericTemplatePayload,
54-
fbotics.models.payloads.generic_template.GenericElement,
55-
fbotics.models.payloads.generic_template.GenericDefaultAction,
56-
fbotics.models.payloads.rich_media.RichMediaPayload
78+
fbotics.models.attachment.Attachment,
5779
],
58-
}
80+
},
5981
]
6082

6183
ROOT = 'http://fbotics.io/'
6284

85+
def get_class_attr(Cls) -> []:
86+
import re
87+
return [a for a, v in Cls.__dict__.items()
88+
if not re.match('<function.*?>', str(v))
89+
and not (a.startswith('__') and a.endswith('__'))]
90+
91+
def get_class_attr_val(cls):
92+
attr = get_class_attr(type(cls))
93+
attr_dict = {}
94+
for a in attr:
95+
attr_dict[a] = getattr(cls, a)
96+
return attr_dict
97+
6398

6499
def get_function_signature(function, method=True):
65100
wrapped = getattr(function, '_original_function', None)
101+
66102
if wrapped is None:
67103
signature = inspect.getargspec(function)
68104
else:
@@ -93,17 +129,23 @@ def get_function_signature(function, method=True):
93129

94130

95131
def get_class_signature(cls):
96-
try:
97-
class_signature = get_function_signature(cls.__init__)
98-
class_signature = class_signature.replace('__init__', cls.__name__)
99-
except (TypeError, AttributeError):
100-
# in case the class inherits from object and does not
101-
# define __init__
102-
class_signature = "{clean_module_name}.{cls_name}()".format(
103-
clean_module_name=clean_module_name(cls.__module__),
104-
cls_name=cls.__name__
105-
)
106-
return post_process_signature(class_signature)
132+
signature = '%s.%s(' % (cls.__module__, cls.__name__)
133+
class_attr_value_dict = get_class_attr_val(cls())
134+
class_attr_value_dict.pop("_schema")
135+
for k, v in class_attr_value_dict.items():
136+
signature += str(k) + "=" + str(v) + ', '
137+
signature = signature[:-2] + ')'
138+
#try:
139+
# class_signature = get_function_signature(cls.__init__)
140+
# class_signature = class_signature.replace('__init__', cls.__name__)
141+
#except (TypeError, AttributeError):
142+
# # in case the class inherits from object and does not
143+
# # define __init__
144+
# class_signature = "{clean_module_name}.{cls_name}()".format(
145+
# clean_module_name=clean_module_name(cls.__module__),
146+
# cls_name=cls.__name__
147+
# )
148+
return post_process_signature(signature)
107149

108150

109151
def post_process_signature(signature):

docs/mkdocs.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
site_name: FBotics Documentation
2-
theme: readthedocs
2+
theme: material
33
site_description: 'Documentation for FBotics, the Python Client for Facebook Send API'
44
docs_dir: sources
55
site_url: https://pasmod.github.io/fbotics/
66

7-
87
dev_addr: '0.0.0.0:8000'
98

109
nav:
1110
- Home: index.md
12-
- Send API: fbotics.md
11+
- Send API:
12+
- Client: send/client.md
13+
- Request: send/request.md
14+
- Recipient: send/recipient.md
15+
- Message: send/message.md
16+
- Attachment: send/attachment.md
17+
- Quick Replies:
18+
- Quick Reply: quick_replies/quick_replies.md
19+
- Example: quick_replies/example.md
1320
- Buttons: buttons.md
21+
- Button Template:
22+
- Template Payload: _templates/button_template/button_template.md
23+
- Example: _templates/button_template/example.md
24+
- Generic Template:
25+
- Template Payload: _templates/generic_template/generic_template.md
26+
- Example: _templates/generic_template/example.md
1427
- Message: message.md
15-
- Template Payloads: templates.md
28+
- Template Payloads: button_template.md
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The button template allows you to send a structured message that includes text and buttons.
2+
3+
{{autogenerated}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
{{autogenerated}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
{{autogenerated}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The generic template allows you to send a structured message that includes an image, text and buttons. A generic template with multiple templates described in the elements array will send a horizontally scrollable carousel of items, each composed of an image, text and buttons.
2+
3+
{{autogenerated}}
File renamed without changes.

docs/templates/fbotics.md

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{autogenerated}}
2+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Quick Replies allow you to get message recipient input by sending buttons in a message. When a quick reply is tapped, the value of the button is sent in the conversation, and the Messenger Platform sends a messages event to you webhook.
2+
3+
{{autogenerated}}
4+

0 commit comments

Comments
 (0)