Skip to content

Commit 305e0c3

Browse files
Add markdownlint (#1664)
- Add a markdown linter to the `gh-pages` workflow. - Fix some lint warnings. - Fix incorrect file name. Contributes to #1639.
1 parent 094dec8 commit 305e0c3

File tree

11 files changed

+119
-63
lines changed

11 files changed

+119
-63
lines changed

.github/ISSUE_TEMPLATE/bug-.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug?
3+
about: "... or something not behaving as expected?"
4+
---
5+
6+
# Bug Report
7+
8+
## Summary
9+
10+
## Expected behavior
11+
12+
## Actual behaviour
13+
14+
## Steps / Code to reproduce the problem
15+
16+
<!-- Best is a [complete runnable example](https://stackoverflow.com/help/mcve) or failing unit test. -->

.github/ISSUE_TEMPLATE/how-to.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
---
2-
name: How to
3-
about: You have something specific to achieve and the existing documentation hasn't
4-
covered how.
2+
name: How to?
3+
about: You have something specific to achieve and the existing documentation hasn't covered how.
54
---
65

7-
<!--
8-
Be sure to check out the ReadMe (https://github.com/App-vNext/Polly/blob/main/README.md) and wiki (https://github.com/App-vNext/Polly/wiki) first!
6+
<!--
97
10-
https://github.com/App-vNext/Polly/wiki contains detailed pages on each policy type. Many questions are answered there about policy operation, how to change operation with configuration options, and how to attach behaviour via delegates. Other wiki pages cover [unit-testing](https://github.com/App-vNext/Polly/wiki/Unit-testing-with-Polly), [async usage](https://github.com/App-vNext/Polly/wiki/Asynchronous-action-execution), common patterns, and [using HttpClientFactory in ASP.NET Core 2.1 as the best way to integrate Polly into outbound `HttpClient` calls](https://github.com/App-vNext/Polly/wiki/Polly-and-HttpClientFactory).
8+
Be sure to check out the README (https://github.com/App-vNext/Polly/blob/main/README.md) and documentation (https://www.pollydocs.org/) first!
119
1210
-->
1311

14-
**Summary: What are you wanting to achieve?**
12+
# How to?
1513

16-
**What code or approach do you have so far?**
14+
## What are you wanting to achieve?
1715

18-
It is _always_ useful to see:
16+
## What code or approach do you have so far?
1917

20-
+ **code of any policy declarations**,
21-
+ **code of the calls to `.Execute/AndCapture/Async(...)`**
18+
<!--
19+
20+
Best is a [complete runnable example](https://stackoverflow.com/help/mcve)
21+
22+
-->

.github/ISSUE_TEMPLATE/request.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
2-
name: Request
2+
name: Feature Request
33
about: Suggest a feature request or improvement
4-
54
---
65

7-
**Is your feature request related to a specific problem? Or an existing feature? Please describe.**
8-
9-
10-
**Describe your proposed or preferred solution**:
6+
# Feature Request
117

8+
## Is your feature request related to a specific problem? Or an existing feature?
129

13-
**Describe any alternative options you've considered**:
10+
## Describe your proposed or preferred solution
1411

12+
## Describe any alternative options you've considered
1513

16-
**Any additional info?**
14+
## Any additional info?

.github/pull_request_template.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<!-- Thank you for contributing to Polly! Open source is only as strong as its contributors. All non-trivial contributions get a public credit in the readme! -->
1+
<!-- Thank you for contributing to Polly! Open source is only as strong as its contributors. -->
22

3-
### The issue or feature being addressed
3+
# Pull Request
4+
5+
## The issue or feature being addressed
46

57
<!-- Please include the existing GitHub issue number where relevant -->
68

7-
### Details on the issue fix or feature implementation
9+
## Details on the issue fix or feature implementation
810

9-
### Confirm the following
11+
## Confirm the following
1012

1113
- [ ] I started this PR by branching from the head of the default branch
1214
- [ ] I have targeted the PR to merge into the default branch

.github/workflows/gh-pages.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
2424

25+
- name: Lint Markdown files
26+
uses: DavidAnson/markdownlint-cli2-action@ed4dec634fd2ef689c7061d5647371d8248064f1 # v13.0.0
27+
with:
28+
config: '.markdownlint.json'
29+
globs: |
30+
**/*.md
31+
!CHANGELOG.md
32+
!**/BenchmarkDotNet.Artifacts/**/*.md
33+
2534
- name: Setup .NET SDK
2635
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
2736

.markdownlint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"MD013": false,
3+
"MD033": {
4+
"allowed_elements": [
5+
"br",
6+
"img",
7+
"sub"
8+
]
9+
}
10+
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# CHANGELOG
2+
13
## 8.0.0
24

35
* Updates for beta.2 by [@martincostello](https://github.com/martincostello) in https://github.com/App-vNext/Polly/pull/1580

CODE_OF_CONDUCT.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
Polly is part of the [.NET Foundation](https://dotnetfoundation.org/), and we ask our contributors to abide by their [Code of Conduct](https://www.dotnetfoundation.org/code-of-conduct).
1+
# Code of Conduct
2+
3+
Polly is part of the [.NET Foundation][dnf], and we ask our contributors to abide
4+
by their [Code of Conduct][dnf-coc].
5+
6+
[dnf]: https://dotnetfoundation.org/
7+
[dnf-coc]: https://www.dotnetfoundation.org/code-of-conduct

docs/advanced/dependency-injection.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Dependency injection
22

3-
Starting with version 8, Polly provides features that make the integration of Polly with the .NET [`IServiceCollection`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) Dependency Injection (DI) container more streamlined. This is a thin layer atop the [resilience pipeline registry](../pipelines/resilience-pipeline-registry.md) which manages resilience pipelines.
3+
Starting with version 8, Polly provides features that make the integration of Polly
4+
with the .NET [`IServiceCollection`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection)
5+
Dependency Injection (DI) container more streamlined. This is a thin layer atop the
6+
[resilience pipeline registry](../pipelines/resilience-pipeline-registry.md) which
7+
manages resilience pipelines.
48

59
## Usage
610

7-
To use the DI functionality, add the [`Polly.Extensions`](https://www.nuget.org/packages/Polly.Extensions) package to your project:
11+
To use the DI functionality, add the [`Polly.Extensions`](https://www.nuget.org/packages/Polly.Extensions)
12+
package to your project:
813

914
```sh
1015
dotnet add package Polly.Extensions
1116
```
1217

13-
Afterwards, you can use the `AddResiliencePipeline(...)` extension method to set up your pipeline:
18+
Afterwards, you can use the `AddResiliencePipeline(...)` extension method to set
19+
up your pipeline:
1420

1521
<!-- snippet: add-resilience-pipeline -->
1622
```cs
@@ -44,20 +50,24 @@ await pipeline.ExecuteAsync(
4450
```
4551
<!-- endSnippet -->
4652

47-
The `AddResiliencePipeline` extension method also registers the following services into the DI:
53+
The `AddResiliencePipeline` extension method also registers the following services
54+
into the DI container:
4855

4956
- `ResiliencePipelineRegistry<string>`: Allows adding and retrieving resilience pipelines.
5057
- `ResiliencePipelineProvider<string>`: Allows retrieving resilience pipelines.
5158
- `IOptions<ResiliencePipelineRegistryOptions<string>>`: Options for `ResiliencePipelineRegistry<string>`.
5259

5360
> [!NOTE]
54-
> The generic `string`` is inferred since the pipeline was defined using the "my-key" value.
61+
> The generic `string`` is inferred since the pipeline was defined using the
62+
> "my-key" value.
5563
56-
If you only need the registry without defining a pipeline, use the `AddResiliencePipelineRegistry(...)` method.
64+
If you only need the registry without defining a pipeline, use the
65+
`AddResiliencePipelineRegistry(...)` method.
5766

5867
### Generic resilience pipelines
5968

60-
You can also define generic resilience pipelines (`ResiliencePipeline<T>`), as demonstrated below:
69+
You can also define generic resilience pipelines (`ResiliencePipeline<T>`), as
70+
demonstrated below:
6171

6272
<!-- snippet: add-resilience-pipeline-generic -->
6373
```cs
@@ -92,7 +102,9 @@ await pipeline.ExecuteAsync(
92102

93103
## Dynamic reloads
94104

95-
Dynamic reloading is a feature of the pipeline registry that is also surfaced when using the `AddResiliencePipeline(...)` extension method. Use an overload that provides access to `AddResiliencePipelineContext`:
105+
Dynamic reloading is a feature of the pipeline registry that is also surfaced when
106+
using the `AddResiliencePipeline(...)` extension method. Use an overload that provides
107+
access to `AddResiliencePipelineContext`:
96108

97109
<!-- snippet: di-dynamic-reloads -->
98110
```cs
@@ -121,11 +133,14 @@ During a reload:
121133
- The callback re-executes.
122134
- The previous pipeline is discarded.
123135

124-
If an error occurs during reloading, the old pipeline remains, and dynamic reloading stops.
136+
If an error occurs during reloading, the old pipeline remains, and dynamic
137+
reloading stops.
125138

126139
## Resource disposal
127140

128-
Like dynamic reloading, the pipeline registry's resource disposal feature lets you register callbacks. These callbacks run when the pipeline is discarded, reloaded, or the registry is disposed at application shutdown.
141+
Like dynamic reloading, the pipeline registry's resource disposal feature lets
142+
you register callbacks. These callbacks run when the pipeline is discarded, reloaded,
143+
or the registry is disposed at application shutdown.
129144

130145
See the example below:
131146

@@ -145,11 +160,14 @@ services.AddResiliencePipeline("my-pipeline", (builder, context) =>
145160
```
146161
<!-- endSnippet -->
147162

148-
This feature ensures that resources are properly disposed when a pipeline reloads, discarding the old version.
163+
This feature ensures that resources are properly disposed when a pipeline
164+
reloads, discarding the old version.
149165

150166
## Complex pipeline keys
151167

152-
The `AddResiliencePipeline(...)` method supports complex pipeline keys. This capability allows you to define the structure of your pipeline and dynamically resolve and cache multiple instances of the pipeline with different keys.
168+
The `AddResiliencePipeline(...)` method supports complex pipeline keys. This
169+
capability allows you to define the structure of your pipeline and dynamically
170+
resolve and cache multiple instances of the pipeline with different keys.
153171

154172
Start by defining your complex key:
155173

@@ -174,7 +192,10 @@ services.AddResiliencePipeline(new MyPipelineKey("my-pipeline", string.Empty), b
174192
```
175193
<!-- endSnippet -->
176194

177-
The "my-pipeline" pipeline is now registered. Note that the `InstanceName` is an empty string. While we're registering the builder action for a specific pipeline, the `InstanceName` parameter isn't used during the pipeline's registration. Some further modifications are required for this to function.
195+
The "my-pipeline" pipeline is now registered. Note that the `InstanceName` is an
196+
empty string. While we're registering the builder action for a specific pipeline,
197+
the `InstanceName` parameter isn't used during the pipeline's registration. Some
198+
further modifications are required for this to function.
178199

179200
Introduce the `PipelineNameComparer`:
180201

@@ -207,11 +228,16 @@ services
207228

208229
Let's summarize our actions:
209230

210-
- We assigned the `PipelineNameComparer` instance to the `BuilderComparer` property. This action changes the default registry behavior, ensuring that only the `PipelineName` is used to find the associated builder.
211-
- We used the `InstanceNameFormatter` delegate to represent the `MyPipelineKey` as an instance name for telemetry purposes, keeping the instance name as it is.
212-
- Likewise, the `BuilderNameFormatter` delegate represents the `MyPipelineKey` as a builder name in telemetry.
231+
- We assigned the `PipelineNameComparer` instance to the `BuilderComparer` property.
232+
This action changes the default registry behavior, ensuring that only the
233+
`PipelineName` is used to find the associated builder.
234+
- We used the `InstanceNameFormatter` delegate to represent the `MyPipelineKey`
235+
as an instance name for telemetry purposes, keeping the instance name as it is.
236+
- Likewise, the `BuilderNameFormatter` delegate represents the `MyPipelineKey` as
237+
a builder name in telemetry.
213238

214-
Finally, use the `ResiliencePipelineProvider<MyPipelineKey>` to dynamically create and cache multiple instances of the same pipeline:
239+
Finally, use the `ResiliencePipelineProvider<MyPipelineKey>` to dynamically create
240+
and cache multiple instances of the same pipeline:
215241

216242
<!-- snippet: di-registry-multiple-instances -->
217243
```cs
@@ -225,10 +251,11 @@ ResiliencePipeline instanceB = pipelineProvider.GetPipeline(new MyPipelineKey("m
225251
```
226252
<!-- endSnippet -->
227253

228-
229254
## Patterns and anti-patterns
230255

231-
Over the years, many developers have used Polly in various ways. Some of these recurring patterns may not be ideal. This section highlights the recommended practices and those to avoid.
256+
Over the years, many developers have used Polly in various ways. Some of these
257+
recurring patterns may not be ideal. This section highlights the recommended practices
258+
and those to avoid.
232259

233260
### 1 - Accessing the `IServiceCollection` instead of `IServiceProvider`
234261

@@ -283,4 +310,5 @@ services.AddResiliencePipeline("myFavoriteStrategy", static (builder, context) =
283310

284311
**Reasoning**:
285312

286-
This approach uses the already built `ServiceProvider` and uses the same instance before every retry attempts.
313+
This approach uses the already built `ServiceProvider` and uses the same instance
314+
before every retry attempts.

0 commit comments

Comments
 (0)