doc: explain how to create a WebView (#43712)#43787
Conversation
Narfinger
left a comment
There was a problem hiding this comment.
Thanks you for improving the documentation! Looks good to me.
| /// [`Servo`] instance and a [`RenderingContext`](crate::RenderingContext) to provide to the | ||
| /// builder: | ||
| /// | ||
| /// ```rust,ignore |
There was a problem hiding this comment.
Might it be better to have a # fn foo(my_delegate: &WebViewDelegate) and then a no_run for this?
There was a problem hiding this comment.
Might it be better to have a
# fn foo(my_delegate: &WebViewDelegate)and then a no_run for this?
I guess we'll still need a servo instance, url, and rendering context to make it compile, no?
Also, what is foo here? Do you mean to say a dummy implementation of WebViewDelegate? i.e
struct MyDelegate;
impl WebViewDelegate for MyDelegate {}
There was a problem hiding this comment.
Yes something like that.
Basically if we can have
# fn foo(servo: &Servo, rendering_context: Rc<dyn RenderingContext>) {
struct MyDelegate;
impl WebViewDelegate for MyDelegate {}
let webview = WebViewBuilder::new(&servo, rendering_context)
url(url)
.delegate(Rc::new(my_delegate))
.build();
# }
As far as I understand the rustdoc documentation this should work because it is code that compiles.
But if there is something more to do then it might not be worth it and this way is fine.
|
@TG199 I believe the scope of the issue was just to have single line to mention that |
|
Okay, thanks |
Signed-off-by: Kelechi Ebiri <[email protected]>
ace2268 to
c623b17
Compare
Added a "Creating a WebView" section to the
WebViewdoc comment explaining thatWebViewBuilderis the correct way to create aWebView, with a usage example. Also expanded theWebViewBuilderdoc comment to be more descriptive.Fixes: #43712