Skip to content

Commit

Permalink
docs: Align code snippet blocks syntax to follow docfx and microsoft …
Browse files Browse the repository at this point in the history
…related documentation

(cherry picked from commit e544b27)
  • Loading branch information
agneszitte authored and mergify[bot] committed Jun 3, 2024
1 parent 7eb922b commit af4a7c3
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion doc/ReleaseNotes/LegacyReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ uid: Uno.ReleaseNotes.Legacy
- **Custom Themes** are supported. This let you specify `HighContrast` or any other custom themes.
(this is a feature not supported in UWP)

``` csharp
```csharp
// Put that somewhere during app initialization...
Uno.UI.ApplicationHelper.RequestedCustomTheme = "MyCustomTheme";
```
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/features/ElevatedView.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ xmlns:toolkit="using:Uno.UI.Toolkit"

After that, use the `ElevatedView` to host the content you need to be elevated:

``` xml
```xml
<StackPanel Orientation="Horizontal" Spacing="20">

<Button>Non-Elevated Button</Button>
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/Lottie.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ Here's how to use this feature:

1. Add a _css-like_ declaration to your Lottie shape like this then put this in the name of the shape. That means the `nm` property in the json-generated file.

``` css
```css
{ Color: var(MyColor); }
```

In that case, it will create a property (variable) named `MyColor`. It is possible to reuse the same property name on many layers in the same lottie file.

2. Use it that way:

``` xml
```xml
<winui:AnimatedVisualPlayer
x:Name="player"
AutoPlay="true">
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/features/applicationdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ string text = await FileIO.ReadTextAsync(file);

The `LocalSettings` and `RoamingSettings` properties provide access to simple key-value containers that allow storage of lightweight user and application preferences. The values stored in settings should be simple serializable types. To store more complex data structures, it is preferred to serialize them first into a string (for example using a JSON serializer).

``` csharp
```csharp
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

// Save a setting.
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/custom-fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ In order to use a custom font in your application:

On Wasm platform, fonts files are loaded by the browser and can take some time to load, resulting in performance degradation and potential flickering when the font is actually available for rendering. In order to prevent this, it is possible to instruct the browser to preload the font before the rendering:

``` csharp
```csharp
// Preloading of font families on Wasm. Add this before the Application.Start() in the Program.cs
public static void Main(string[] args)
Expand Down Expand Up @@ -203,7 +203,7 @@ First, the font needs to be defined in CSS.

Second, you can use it in XAML in this way:

``` xml
```xml
<!-- XAML usage of CSS defined font -->

<TextBlock FontFamily="MyCustomFontAsBase64">This text should be rendered using the font defined as base64 in CSS.</TextBlock>
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/routed-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This article covers some of the finer technical details of Uno Platform's routed

## Event Bubbling Flow

``` plain
```plain
[1]---------------------+
| An event is fired |
+--------+--------------+
Expand Down Expand Up @@ -80,7 +80,7 @@ platform propagate the events. But this will cause more interop between managed
You can control which events are bubbling in managed code by using the `EventsBubblingInManagedCode`
dependency property. The value of this property is inherited to children. Example:

``` csharp
```csharp
// Make sure PointerPressed and PointerReleased are always bubbling in
// managed code when they are originating from myControl and its children.
myControl.EventsBubblingInManagedCode =
Expand Down
10 changes: 5 additions & 5 deletions doc/articles/features/web-authentication-broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uid: Uno.Features.WAB

* You **MUST** declare an activity inheriting from `WebAuthenticationBrokerActivityBase` in the Android head. Note the `[Activity]` attribute needs to include `Exported = true` if you are targeting Android 12.

``` csharp
```csharp
// Android: add this class near the MainActivity, in the head project
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)]
[IntentFilter(
Expand All @@ -52,7 +52,7 @@ uid: Uno.Features.WAB

For special needs, it is possible to create a custom implementation of the Web Authentication Broker by using the `[ApiExtension]` mechanism of Uno and implementing the `IWebAuthenticationBrokerProvider` interface:

``` csharp
```csharp
[assembly: ApiExtension(typeof(MyNameSpace.MyBrokerImplementation), typeof(Uno.AuthenticationBroker.IWebAuthenticationBrokerProvider))]

public class MyBrokerImplementation : Uno.AuthenticationBroker.IWebAuthenticationBrokerProvider
Expand All @@ -74,7 +74,7 @@ On WebAssembly, it is possible to use an in-application `<iframe>` instead of op

1. Create an `<iframe>` control:

``` csharp
```csharp
[HtmlElement("iframe")]
public class LoginIFrame : Control
{
Expand All @@ -89,7 +89,7 @@ On WebAssembly, it is possible to use an in-application `<iframe>` instead of op

2. Use the `LoginIFrame` control in the page:

``` xml
```xml
<Page ...>
<Grid>
[...]
Expand All @@ -100,7 +100,7 @@ On WebAssembly, it is possible to use an in-application `<iframe>` instead of op

3. Set the `HtmlId` before calling the `WebAuthenticationBroker`:

``` csharp
```csharp
private async void LoginHidden_Click(object sender, RoutedEventArgs e)
{
// Set configuration to use the control as the iframe control
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/guides/open-id-connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private async void SignOut_Clicked(object sender, RoutedEventArgs e)
> On WebAssembly, it's important to configure the linker to prevent the removal of some important part of the *OIDC Connect* client library:
> `LinkerConfig.xml`:
>
> ``` xml
> ```xml
> <linker>
> <assembly fullname="My.Oidc.Client.App.Wasm" />
> <assembly fullname="Uno.UI" />
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/interop/MSAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use MSAL into an Uno project, follow the following steps:

3. Change the `IPublicCLientApplication` initialization to add a call to `.WithUnoHelpers()` like this:

``` csharp
```csharp
IPublicClientApplication _app = PublicClientApplicationBuilder.Create(clientId)
[...]
.WithUnoHelpers() // Add this line before the .Build()
Expand All @@ -29,7 +29,7 @@ To use MSAL into an Uno project, follow the following steps:

4. Where you are using the *Interactive* mode (`_app.AcquireTokenInteractive`), add another call to `.WithUnoHelpers()` like this:

``` csharp
```csharp
var authResult = await _app.AcquireTokenInteractive(scopes)
.WithPrompt(Prompt.SelectAccount)
[...]
Expand Down
24 changes: 12 additions & 12 deletions doc/articles/interop/wasm-javascript-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Uno Bootstrapper can automatically embed any asset and deploy them with the

1. **JavaScript files** should be in the `WasmScripts` folder: they will be copied to the output folder and loaded automatically by the bootstrapper when the page loads. **They must be marked with the `EmbeddedResources` build action**:

``` xml
```xml
<!-- .csproj file -->
<ItemGroup>
<EmbeddedResource Include="WasmScripts\javascriptfile.js" />
Expand All @@ -32,7 +32,7 @@ The Uno Bootstrapper can automatically embed any asset and deploy them with the

2. **CSS Style files** should be in the `WasmCSS` folder: they will be copied to the output folder and referenced in the *HTML head* of the application. **They must be marked with the `EmbeddedResources` build action**.

``` xml
```xml
<!-- .csproj file -->
<ItemGroup>
<EmbeddedResource Include="WasmCSS\stylefile.css" />
Expand All @@ -42,7 +42,7 @@ The Uno Bootstrapper can automatically embed any asset and deploy them with the

3. **Asset files** should be marked with the `Content` build action in the app. The file will be copied to the output folder and will preserve the same relative path.

``` xml
```xml
<!-- .csproj file -->
<ItemGroup>
<Content Include="Assets\image.png" />
Expand All @@ -60,7 +60,7 @@ The [philosophy of Uno](../concepts/overview/philosophy-of-uno.md) is to rely on

That also means that it is possible to control how this element is created. By default it is a `<div>`, but it can be changed in the constructor by providing the `htmlTag` parameter to the one required. For example:

``` csharp
```csharp
public sealed partial class MyDivControl : FrameworkElement
{
public MyDivControl() // will create a <div> HTML element (by default)
Expand Down Expand Up @@ -94,7 +94,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

* The extension method `element.SetCssStyle()` can be used to set a CSS Style on the HTML element. Example:

``` csharp
```csharp
// Setting only one CSS style
this.SetCssStyle("text-shadow", "2px 2px red");

Expand All @@ -104,7 +104,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

* The `element.ClearCssStyle()` extension method can be used to set CSS styles to their default values. Example:

``` csharp
```csharp
// Reset text-shadow style to its default value
this.ClearCssStyle("text-shadow");

Expand All @@ -114,7 +114,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

* The `element.SetHtmlAttribute()` and `element.ClearHtmlAttribute()` extension methods can be used to set HTML attributes on the element:

``` csharp
```csharp
// Set the "href" attribute of an <a> element
this.SetHtmlAttribute("href", "#section2");

Expand All @@ -130,7 +130,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

* The `element.SetCssClass()` and `element.UnsetCssClass()` extension methods can be used to add or remove CSS classes to the HTML Element:

``` csharp
```csharp
// Add the class to element
this.SetCssClass("warning");

Expand All @@ -148,7 +148,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

* The `element.SetHtmlContent()` extension method can be used to set arbitrary HTML content as child of the control.

``` csharp
```csharp
this.SetHtmlContent("<h2>Welcome to Uno Platform!</h2>");
```

Expand All @@ -160,7 +160,7 @@ Here is a list of helper methods used to facilitate the integration with the HTM

Whenever there's a need to invoke a JavaScript code in the browser, the `Uno.Foundation.WebAssemblyRuntime` static class should be used. There is also helpers you can call as *extension methods* on the elements.

``` csharp
```csharp
// Invoke javascript synchronously
WebAssemblyRuntime.InvokeJS("alert(\"It works!\");");

Expand Down Expand Up @@ -196,7 +196,7 @@ There's 2 ways to *callback* to managed C# code from JavaScript:

1. Use Mono to wrap a dotnet static method into a JavaScript function like this:JavaScript_:

``` javascript
```javascript
// Register the method wrapper (should be cached)
const sumMethod = Module.mono_bind_static_method(
"[Assembly.Name] Fully.Qualified.ClassType:SumMethod");
Expand All @@ -206,7 +206,7 @@ There's 2 ways to *callback* to managed C# code from JavaScript:

*C#*:

``` csharp
```csharp
// In assembly "Assembly.Name"
namespace Fully.Qualified
{
Expand Down
8 changes: 4 additions & 4 deletions doc/articles/interop/wasm-javascript-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Let's create an app to integrate a Syntax Highlighter named [`PrismJS`](https://

1. First, there is a requirement for _PrismJS_ to set the `white-space` style at a specific value, as [documented here](https://github.com/PrismJS/prism/issues/1237#issuecomment-369846817). An easy way to do this is to set in directly in the constructor like this:

``` csharp
```csharp
public PrismJsView()
{
// This is required to set to <code> style for PrismJS to works well
Expand All @@ -212,7 +212,7 @@ Let's create an app to integrate a Syntax Highlighter named [`PrismJS`](https://

2. Now, we need to create an `UpdateDisplay()` method, used to generate HTML each time there's a new version to update. Here's the code for the method to add in the `PrismJsView` class:

``` csharp
```csharp
private void UpdateDisplay(string oldLanguage = null, string newLanguage = null)
{
string javascript = $@"
Expand Down Expand Up @@ -246,7 +246,7 @@ Let's create an app to integrate a Syntax Highlighter named [`PrismJS`](https://

3. Change `CodeChanged()` and `LanguageChanged()` to call the new `UpdateDisplay()` method:

``` csharp
```csharp
private static void CodeChanged(DependencyObject dependencyobject, DependencyPropertyChangedEventArgs args)
{
(dependencyobject as PrismJsView)?.UpdateDisplay();
Expand All @@ -259,7 +259,7 @@ Let's create an app to integrate a Syntax Highlighter named [`PrismJS`](https://

4. We also need to update the result when the control is loaded in the DOM. So we need to change the constructor again like this:

``` csharp
```csharp
public PrismJsView()
{
// This is required to set to <code> style for PrismJS to works well
Expand Down
14 changes: 7 additions & 7 deletions doc/articles/interop/wasm-javascript-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

1. Create a new _JavaScript_ file `flatpickrloader.js` in the `WasmScripts` folder of the `.Wasm` project:

``` javascript
```javascript
(function () {
const head = document.getElementsByTagName("head")[0];

Expand All @@ -49,7 +49,7 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

2. Set the file as `Embedded Resource`:

``` xml
```xml
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
Expand All @@ -63,7 +63,7 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

1. Create a `FlatpickrView.cs` class in the `[MyApp]` project like this:

``` csharp
```csharp
using System;
using System.Globalization;
using Windows.UI;
Expand Down Expand Up @@ -134,7 +134,7 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

2. Change the `MainPage.xaml` in the `[MyApp]` project like this:

``` xml
```xml
<Page
x:Class="FlatpickrDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Expand Down Expand Up @@ -169,15 +169,15 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

1. Register event handlers for 2 custom events: `DateChanged` and `OpenedStateChanged`. To achieve this, put this code at the end of the `FlatpickrView` constructor:

``` csharp
```csharp
// Register event handler for custom events from the DOM
this.RegisterHtmlCustomEventHandler("DateChanged", OnDateChanged, isDetailJson: false);
this.RegisterHtmlCustomEventHandler("OpenedStateChanged", OnOpenedStateChanged, isDetailJson: false);
```

2. Add the implementation for the two handlers in the class:

``` csharp
```csharp
private void OnDateChanged(object sender, HtmlCustomEventArgs e)
{
if(DateTimeOffset.TryParse(e.Detail, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeLocal, out var dto))
Expand All @@ -202,7 +202,7 @@ An easy way to achieve this is to add JavaScript code to load the CSS file direc

3. Change the initialization of `Flatpickr` in injected JavaScript to raise events. Change the implementation of the `OnLoaded` method to this instead:

``` csharp
```csharp
private void LoadJavaScript()
{
// For demo purposes, Flatpickr is loaded directly from CDN.
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/signalr.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ uid: Uno.Development.SignalR

3. In your `Startup.cs` file, add your `SignalR` service and a `CORS policy` to the `ConfigureServices` method.

``` csharp
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
Expand All @@ -39,7 +39,7 @@ uid: Uno.Development.SignalR

4. In your `Configure` method, add your CORS policy and `Hubs` endpoint

``` csharp
```csharp
app.UseCors("CorsPolicy");

app.UseEndpoints(endpoints =>
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/splash-screen.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ While the new templates simplify adding a splash screen, this article covers how

* Add your image path to the `Image View`

``` xml
```xml
<imageView ... image="Assets/SplashScreen">
```

Expand Down
2 changes: 1 addition & 1 deletion doc/articles/uno-development/building-uno-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Support for building the `Uno.UI` solution is still somewhat unstable, this is a

* If NuGet restore fails when building from the IDE, or if it gets stuck for some other reason, try building from the command line. Open a terminal session in the `uno/src` folder and use the following command:

``` shell
```shell
msbuild /m /r SamplesApp/SamplesApp.macOS/SamplesApp.macOS.csproj
```

Expand Down
Loading

0 comments on commit af4a7c3

Please sign in to comment.