Skip to content

Commit 81b2e48

Browse files
authored
Merge pull request #1580 from MicrosoftEdge/api-spec-template-update
Update API spec template with changes to Project Reunion's template
2 parents 79f85a8 + 7895182 commit 81b2e48

1 file changed

Lines changed: 102 additions & 71 deletions

File tree

specs/template.md

Lines changed: 102 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,63 @@
1-
<!-- USAGE
2-
* Fill in each of the sections (like Background) below
3-
* Wrap code with `single line of code` or ```code block```
4-
* Before submitting, delete all <!-- TEMPLATE marked comments in this file,
1+
<!--
2+
Before submitting, delete all "<!-- TEMPLATE" marked comments in this file,
53
and the following quote banner:
64
-->
75
> See comments in Markdown for how to use this spec template
86
97
<!-- TEMPLATE
10-
The purpose of this spec is to describe a new WebView2 feature and its APIs.
11-
12-
There are two audiences for the spec. The first are people
13-
that want to evaluate and give feedback on the API, as part of
14-
the submission process. When it's complete
15-
it will be incorporated into the public documentation at
16-
docs.microsoft.com (https://docs.microsoft.com/en-us/microsoft-edge/webview2/).
17-
Hopefully we'll be able to copy it mostly verbatim.
18-
So the second audience is everyone that reads there to learn how
19-
and why to use this API.
8+
The purpose of this spec is to describe new APIs, in a way
9+
that will transfer to docs.microsoft.com (https://docs.microsoft.com/en-us/microsoft-edge/webview2/).
10+
11+
There are two audiences for the spec. The first are people that want to evaluate and
12+
give feedback on the API, as part of the submission process.
13+
So the second audience is everyone that reads there to learn how and why to use this API.
14+
Some of this text also shows up in Visual Studio Intellisense.
15+
When the PR is complete, the content within the 'Conceptual Pages' section of the review spec will be incorporated into the public documentation at
16+
http://docs.microsoft.com (DMC).
17+
18+
For example, much of the examples and descriptions in the `RadialGradientBrush` API spec
19+
(https://github.com/microsoft/microsoft-ui-xaml-specs/blob/master/active/RadialGradientBrush/RadialGradientBrush.md)
20+
were carried over to the public API page on DMC
21+
(https://docs.microsoft.com/windows/winui/api/microsoft.ui.xaml.media.radialgradientbrush?view=winui-2.5)
22+
23+
Once the API is on DMC, that becomes the official copy, and this spec becomes an archive.
24+
For example if the description is updated, that only needs to happen on DMC and needn't
25+
be duplicated here.
26+
27+
Examples:
28+
* New set of classes and APIs (Custom Downloads):
29+
https://github.com/MicrosoftEdge/WebView2Feedback/blob/master/specs/CustomDownload.md
30+
* New member on an existing class (BackgroundColor):
31+
https://github.com/MicrosoftEdge/WebView2Feedback/blob/master/specs/BackgroundColor.md
32+
33+
Style guide:
34+
* Use second person; speak to the developer who will be learning/using this API.
35+
(For example "you use this to..." rather than "the developer uses this to...")
36+
* Use hard returns to keep the page width within ~100 columns.
37+
(Otherwise it's more difficult to leave comments in a GitHub PR.)
38+
* Talk about an API's behavior, not its implementation.
39+
(Speak to the developer using this API, not to the team implementing it.)
40+
* A picture is worth a thousand words.
41+
* An example is worth a million words.
42+
* Keep examples realistic but simple; don't add unrelated complications.
43+
(An example that passes a stream needn't show the process of launching the File-Open dialog.)
44+
* Use GitHub flavored Markdown: https://guides.github.com/features/mastering-markdown/
45+
2046
-->
2147

48+
Title
49+
===
2250

2351
# Background
2452
<!-- TEMPLATE
2553
Use this section to provide background context for the new API(s)
26-
in this spec.
54+
in this spec. Try to briefly provide enough information to be able to read
55+
the rest of the document.
2756
2857
This section and the appendix are the only sections that likely
2958
do not get copied into any official documentation, they're just an aid
30-
to reading this spec.
59+
to reading this spec. If you find useful information in the background
60+
or appendix consider moving it to documentation.
3161
3262
If you're modifying an existing API, included a link here to the
3363
existing page(s) or spec documentation.
@@ -40,15 +70,24 @@
4070
the reader "go read 100 pages of background information posted at ...".
4171
-->
4272

43-
In this document we describe the updated API. We'd appreciate your feedback.
73+
# Conceptual pages (How To)
4474

75+
_(This is conceptual documentation that will go to docs.microsoft.com "how to" page)_
4576

46-
# Description
4777
<!-- TEMPLATE
48-
Use this section to provide a brief description of the feature.
78+
(Optional)
79+
80+
All APIs have reference docs, but some APIs or groups of APIs have an additional high level,
81+
conceptual page (called a "how-to" page). This section can be used for that content.
82+
83+
For example, there are several navigation events each with their own reference doc, but then
84+
there's also a concept doc on navigation
85+
(https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/navigation-events).
4986
50-
For an example, see the introduction to the PasswordBox control
51-
(http://docs.microsoft.com/windows/uwp/design/controls-and-patterns/password-box).
87+
Sometimes it's difficult to decide if text belongs on a how-to page or an API page.
88+
Because our API reference documentation is automatically turned into reference docs you can
89+
lean towards including text in the API documentation below instead of in this conceptual
90+
section.
5291
-->
5392

5493

@@ -57,6 +96,7 @@ In this document we describe the updated API. We'd appreciate your feedback.
5796
Use this section to explain the features of the API, showing
5897
example code with each description in both C# (for our WinRT API or .NET API) and
5998
in C++ for our COM API. Use snippets of the sample code you wrote for the sample apps.
99+
The sample code for C++ and C# should demonstrate the same thing.
60100
61101
The general format is:
62102
@@ -100,78 +140,69 @@ In this document we describe the updated API. We'd appreciate your feedback.
100140
}
101141
```
102142
103-
As an example of this section, see the Examples section for the PasswordBox
104-
control (https://docs.microsoft.com/windows/uwp/design/controls-and-patterns/password-box#examples).
105-
-->
106-
107-
108-
# Remarks
109-
<!-- TEMPLATE
110-
Explanation and guidance that doesn't fit into the Examples section.
111-
112-
APIs should only throw exceptions in exceptional conditions; basically,
113-
only when there's a bug in the caller, such as argument exception. But if for some
114-
reason it's necessary for a caller to catch an exception from an API, call that
115-
out with an explanation either here or in the Examples
116-
-->
117-
118-
119-
# API Notes
120-
<!-- TEMPLATE
121-
Option 1: Give a one or two line description of each API (type and member),
122-
or at least the ones that aren't obvious from their name. These
123-
descriptions are what show up in IntelliSense. For properties, specify
124-
the default value of the property if it isn't the type's default (for
125-
example an int-typed property that doesn't default to zero.)
126-
127-
Option 2: Put these descriptions in the below API Details section,
128-
with a "///" comment above the member or type.
143+
As an example of this section, see the Examples section for the Custom Downloads
144+
APIs (https://github.com/MicrosoftEdge/WebView2Feedback/blob/master/specs/CustomDownload.md).
129145
-->
130146

131-
132147
# API Details
133148
<!-- TEMPLATE
134149
The exact API, in IDL format for our COM API and
135150
in MIDL3 format (https://docs.microsoft.com/en-us/uwp/midl-3/)
136-
when possible, or in C# if starting with an API sketch for our .NET and WinRT API.
151+
when possible.
137152
138153
Include every new or modified type but use // ... to remove any methods,
139154
properties, or events that are unchanged.
140155
156+
For the MIDL3 parts, after running build-apiwriter, open the generated
157+
`Microsoft.Web.WebView2.Core.idl` and find the new or modified portions
158+
generated from your modifications to the COM IDL.
159+
141160
(GitHub's markdown syntax formatter does not (yet) know about MIDL3, so
142161
use ```c# instead even when writing MIDL3.)
143162
144163
Example:
145164
146-
```
147-
/// Event args for the NewWindowRequested event. The event is fired when content
148-
/// inside webview requested to open a new window (through window.open() and so on.)
149-
[uuid(34acb11c-fc37-4418-9132-f9c21d1eafb9), object, pointer_default(unique)]
150-
interface ICoreWebView2NewWindowRequestedEventArgs : IUnknown
165+
```
166+
[uuid(B625A89E-368F-43F5-BCBA-39AA6234CCF8), object, pointer_default(unique)]
167+
interface ICoreWebView2Settings4 : ICoreWebView2Settings3 {
168+
/// The IsPinchZoomEnabled property enables or disables the ability of
169+
/// the end user to use a pinching motion on touch input enabled devices
170+
/// to scale the web content in the WebView2. It defaults to TRUE.
171+
/// When set to FALSE, the end user cannot pinch zoom.
172+
/// This API only affects the Page Scale zoom and has no effect on the
173+
/// existing browser zoom properties (IsZoomControlEnabled and ZoomFactor)
174+
/// or other end user mechanisms for zooming.
175+
///
176+
/// \snippet SettingsComponent.cpp TogglePinchZooomEnabled
177+
[propget] HRESULT IsPinchZoomEnabled([out, retval] BOOL* enabled);
178+
/// Set the IsPinchZoomEnabled property
179+
[propput] HRESULT IsPinchZoomEnabled([in] BOOL enabled);
180+
}
181+
```
182+
183+
```c# (but really MIDL3)
184+
namespace Microsoft.Web.WebView2.Core
185+
{
186+
runtimeclass CoreWebView2Settings
151187
{
152188
// ...
153189
154-
/// Window features specified by the window.open call.
155-
/// These features can be considered for positioning and sizing of
156-
/// new webview windows.
157-
[propget] HRESULT WindowFeatures([out, retval] ICoreWebView2WindowFeatures** windowFeatures);
190+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Settings5")]
191+
{
192+
Boolean IsPinchZoomEnabled { get; set; };
193+
}
158194
}
159-
```
160-
161-
```c# (but really MIDL3)
162-
public class CoreWebView2NewWindowRequestedEventArgs
163-
{
164-
// ...
165-
166-
public CoreWebView2WindowFeatures WindowFeatures { get; }
167-
}
168-
```
195+
}
196+
```
169197
-->
170198

171199

172200
# Appendix
173201
<!-- TEMPLATE
174-
Anything else that you want to write down for posterity, but
175-
that isn't necessary to understand the purpose and usage of the API.
176-
For example, implementation details or links to other resources.
202+
Anything else that you want to write down about implementation notes and for posterity,
203+
but that isn't necessary to understand the purpose and usage of the API.
204+
205+
This or the Background section are a good place to describe alternative designs
206+
and why they were rejected, any relevant implementation details, or links to other
207+
resources.
177208
-->

0 commit comments

Comments
 (0)