@@ -134,12 +134,80 @@ function metadata_model(
134
134
parentmodule (T). eval (ex)
135
135
end
136
136
137
- function doc_header (model)
138
- name = MLJModelInterface. name (model)
139
- human_name = MLJModelInterface. human_name (model)
140
- package_name = MLJModelInterface. package_name (model)
141
- package_url = MLJModelInterface. package_url (model)
142
- params = MLJModelInterface. hyperparameters (model)
137
+ # TODO : After `human_name` trait is added as model trait, include in
138
+ # example given in the docstring for `doc_header`.
139
+
140
+ """
141
+ MLJModelInterface.doc_header(SomeModelType)
142
+
143
+ Return a string suitable for interpolation in the document string of
144
+ an MLJ model type. In the example given below, the header expands to
145
+ something like this:
146
+
147
+ > `FooRegressor`
148
+ >
149
+ >Model type for foo regressor, based on [FooRegressorPkg](http://existentialcomics.com/).
150
+ >
151
+ >From MLJ, the type can be imported using
152
+ >
153
+ >
154
+ > `FooRegressor = @load FooRegressor pkg=FooRegressorPkg`
155
+ >
156
+ >Construct an instance with default hyper-parameters using the syntax
157
+ >`model = FooRegressor()`. Provide keyword arguments to override
158
+ >hyper-parameter defaults, as in `FooRegressor(a=...)`.
159
+
160
+ Ordinarily `doc_header` is used in document strings defined *after*
161
+ the model type definition, as `doc_header` assumes model traits (in
162
+ particular, `package_name` and `package_url`) to be defined; see also
163
+ [`MLJModelInterface.metadata_pkg`](@ref).
164
+
165
+
166
+ ### Example
167
+
168
+ Suppose a model type and traits have been defined by:
169
+
170
+ ```
171
+ mutable struct FooRegressor
172
+ a::Int
173
+ b::Float64
174
+ end
175
+
176
+ metadata_pkg(FooRegressor,
177
+ name="FooRegressorPkg",
178
+ uuid="10745b16-79ce-11e8-11f9-7d13ad32a3b2",
179
+ url="http://existentialcomics.com/",
180
+ )
181
+ metadata_model(FooRegressor,
182
+ input=Table(Continuous),
183
+ target=AbstractVector{Continuous},
184
+ descr="La di da")
185
+ ```
186
+
187
+ Then the docstring is defined post-facto with the following code:
188
+
189
+ ```
190
+ const HEADER = MLJModelInterface.doc_header(FooRegressor)
191
+
192
+ @doc \"\"\"
193
+ \$ HEADER
194
+
195
+ ### Training data
196
+
197
+ In MLJ or MLJBase, bind an instance `model` ...
198
+
199
+ <rest of doc string goes here>
200
+
201
+ \"\"\" FooRegressor
202
+ ```
203
+
204
+ """
205
+ function doc_header (SomeModelType)
206
+ name = MLJModelInterface. name (SomeModelType)
207
+ human_name = MLJModelInterface. human_name (SomeModelType)
208
+ package_name = MLJModelInterface. package_name (SomeModelType)
209
+ package_url = MLJModelInterface. package_url (SomeModelType)
210
+ params = MLJModelInterface. hyperparameters (SomeModelType)
143
211
144
212
ret =
145
213
"""
0 commit comments