1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! # Stores and retrieves interactive help topics
//!
//! The [`HelpSystem`] API stores a list of help topics, which userscripts
//! and interactive users can print by looking up the topic name. It
//! provides the Lua function `help 'topic'`, which prints detailed
//! help information on a given topic.
//!
//! ## Userscript API
//!
//! This is a userscript API. The API's functionality is registered with
//! the Lua virtual machine, where userscripts can call into it.
//!
//! ### API Usage Examples
//!
//! ```text
//! Usage: help()
//! Print generic help information.
//!
//! Usage: help:topics()
//! Print a list of all help topics.
//!
//! Usage: help 'topic'
//! Print detailed help on a topic.
//! ```
use crate::;
use Error;
use ;
use HashMap;
// List of Userscript API Topics
topics!
/// # A help topic for userscript APIs.
///
/// Any type implementing this trait is eligible to be registered with
/// the [`HelpSystem`] as a help topic.
///
/// ## Example
///
/// ```
/// # use sscan::userscript_api::help_system::HelpTopic;
/// // Let's define a help topic.
/// struct MyHelpTopic;
///
/// // Provide the required help information.
/// impl HelpTopic for MyHelpTopic {
/// fn name(&self) -> &'static str {
/// "my_help_topic"
/// }
///
/// fn short_description(&self) -> &'static str {
/// "An example help topic for the help system."
/// }
///
/// fn content(&self) -> &'static str {
/// "
/// # MY HELP TOPIC #\n\
/// \
/// Here we can provide long-form, detailed help content for our topic. Each\
/// line should be no longer than 73 characters to prevent wrapping in most\
/// user's terminals, however, the content can span multiple paragraphs.\n\
/// \
/// The help content should be descriptive for end-users. For example, when\
/// documenting an API function, provide details on how to call the function,\
/// what arguments it takes, the expected return value(s), and any errors\
/// that might occur.\n\
/// \
/// For convenience, use the include_str!() function to add help content\
/// from a separate file instead of an inline string.
/// "
/// }
/// }
/// ```
///
/// Once we've registered our topic with the [`HelpSystem`], users and
/// userscripts can look up the help content using:
///
/// ```lua
/// help 'my_help_topic'
/// ```