Skip to content

Commit 0a223b9

Browse files
authored
Documentation: introduce clickable copy to clipboard headers for all pages and a hx-tags (#729)
1 parent 3dd1f75 commit 0a223b9

30 files changed

+135
-75
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ DEPENDENCIES
5656
ruby_dep (~> 1.3)
5757

5858
BUNDLED WITH
59-
1.17.2
59+
1.17.2

docs/_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8" />
55
<title>NSubstitute: {{ page.title }}</title>
66
<link rel="stylesheet" href="/css/style.css" type="text/css" />
7+
<script src="{{ base.url | prepend: site.url }}/js/scripts.js"></script>
78
</head>
89
<body>
910
<div id="header">

docs/css/style.css

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
html { font-family: "helvetica", Helvetica, Arial }
22
body {
3-
margin:0;
4-
padding:0;
5-
border:0;
6-
width:100%;
7-
min-width:600px;
3+
margin: 0;
4+
padding: 0;
5+
border: 0;
6+
width: 100%;
7+
min-width: 600px;
88
}
99

10-
p{
11-
font-size:1.0em;
12-
line-height:1.6;
10+
p {
11+
font-size: 1.0em;
12+
line-height: 1.6;
1313
}
1414

1515
ul {
16-
font-size:1.0em;
17-
line-height:1.6;
16+
font-size: 1.0em;
17+
line-height: 1.6;
1818
}
1919

20-
h1{font-size:2.5em}
21-
h2{font-size:2.0em}
22-
h3{font-size:1.5em}
20+
h1{font-size: 2.5em}
21+
h2{font-size: 2.0em}
22+
h3{font-size: 1.5em}
2323

2424
a:link { color: #365f91; text-decoration: none;}
2525
a:visited { color: #365f91; text-decoration: none;}
@@ -80,7 +80,7 @@ a:active { color: #000000; text-decoration: underline;}
8080
#post-content {
8181
float: left;
8282
position: relative;
83-
width:71%;
83+
width: 71%;
8484
padding-left: 10px;
8585
}
8686

@@ -181,6 +181,42 @@ code {
181181
min-height: inherit !important;
182182
}
183183

184+
h1 {
185+
margin-top: 0.5em;
186+
margin-bottom: 0.2em;
187+
}
188+
189+
h2 {
190+
position: relative;
191+
display: inline-block;
192+
margin-top: 0.5em;
193+
margin-bottom: 0.2em;
194+
}
195+
196+
h3 {
197+
position: relative;
198+
display: inline-block;
199+
margin-top: 0.5em;
200+
margin-bottom: 0.2em;
201+
}
202+
203+
.tooltip {
204+
visibility: visible;
205+
color: #365f91;
206+
background-color: #ECF0F5;
207+
position: absolute;
208+
z-index: 1;
209+
white-space: nowrap;
210+
font-size: 0.4em;
211+
padding: 0.6em;
212+
margin: 0.4em auto auto 0.6em;
213+
border-radius: 30px;
214+
}
215+
216+
.tooltip-hidden {
217+
visibility: hidden;
218+
}
219+
184220
/* Pygments vs style, as generated by:
185221
* https://github.com/richleland/pygments-css/blob/master/vs.css
186222
*/
@@ -222,4 +258,4 @@ code {
222258
.highlight .sr { color: #a31515 } /* Literal.String.Regex */
223259
.highlight .s1 { color: #a31515 } /* Literal.String.Single */
224260
.highlight .ss { color: #a31515 } /* Literal.String.Symbol */
225-
/* End pygments vs style */
261+
/* End pygments vs style */

docs/help/_posts/2010-01-01-getting-started.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ calculator.PoweringUp += Raise.Event();
119119
Assert.That(eventWasRaised);
120120
```
121121

122-
That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports.
122+
That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports.

docs/help/_posts/2010-01-02-creating-a-substitute.markdown

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,4 @@ Assert.AreEqual("hello", func());
9898

9999
## Partial substitutes and test spies
100100

101-
When required we can also create substitutes that run real code by default, letting us replace [specific parts of a class with substitute behaviour](/help/partial-subs/).
102-
103-
104-
101+
When required we can also create substitutes that run real code by default, letting us replace [specific parts of a class with substitute behaviour](/help/partial-subs/).

docs/help/_posts/2010-02-01-set-return-value.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,4 @@ Assert.AreEqual(calculator.Mode, "HEX");
5252

5353

5454
## More ways of setting return values
55-
This covers the very basics of setting a return value, but NSubstitute can do much more. Read on for other approachs, including [matching specific arguments](/help/return-for-args), [ignoring arguments](/help/return-for-any-args), using [functions to calculate return values](/help/return-from-function) and returning [multiple results](/help/multiple-returns).
56-
55+
This covers the very basics of setting a return value, but NSubstitute can do much more. Read on for other approachs, including [matching specific arguments](/help/return-for-args), [ignoring arguments](/help/return-for-any-args), using [functions to calculate return values](/help/return-from-function) and returning [multiple results](/help/multiple-returns).

docs/help/_posts/2010-02-02-return-for-args.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ Assert.AreNotEqual(345, calculator.Add(1, 2));
3131
//Return when both args equal to 0:
3232
calculator.Add(Arg.Is(0), Arg.Is(0)).Returns(99);
3333
Assert.AreEqual(99, calculator.Add(0, 0));
34-
```
35-
34+
```

docs/help/_posts/2010-02-03-return-for-any-args.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ calculator.Add(default, default).ReturnsForAnyArgs(100);
3030

3131
The same behaviour can also be achieved using [argument matchers](/help/argument-matchers): it is simply a shortcut for replacing each argument with `Arg.Any<T>()`.
3232

33-
`ReturnsForAnyArgs()` has the same overloads as `Returns()`, so you can also specify multiple return values or calculated return values using this approach.
33+
`ReturnsForAnyArgs()` has the same overloads as `Returns()`, so you can also specify multiple return values or calculated return values using this approach.

docs/help/_posts/2010-02-03-return-from-function.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ calculator
7979
calculator.Add(7,3);
8080
calculator.Add(2,2);
8181
Assert.AreEqual(counter, 2);
82-
```
82+
```

docs/help/_posts/2010-02-04-multiple-returns.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ Assert.Throws<Exception>(() => { var result = calculator.Mode; });
3838

3939
## Configuring other calls without using up multiple returns
4040

41-
If a call has been configured with multiple returns values, you can configure a more specific call without using up any of these callbacks using [`.Configure()`](/help/configure/).
42-
41+
If a call has been configured with multiple returns values, you can configure a more specific call without using up any of these callbacks using [`.Configure()`](/help/configure/).

docs/help/_posts/2010-02-10-replacing-return-values.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ public void SetUp() {
2323
calculator = Substitute.For<ICalculator>();
2424
}
2525
```
26-
-->
27-
26+
-->

docs/help/_posts/2010-03-01-received-calls.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,4 @@ public void ShouldRaiseLowFuel(){
237237
.Received()
238238
.Invoke(fuelManagement, Arg.Is<LowFuelWarningEventArgs>(x => x.PercentLeft < 20));
239239
}
240-
```
241-
240+
```

docs/help/_posts/2010-03-10-clear-received-calls.markdown

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ runner.Run();
4343
command.DidNotReceive().Execute();
4444
```
4545

46-
`ClearReceivedCalls()` will not clear any results set up for the substitute using `Returns()`. If we need to this, we can [replace previously specified results](/help/replacing-return-values) by calling `Returns()` again.
47-
48-
46+
`ClearReceivedCalls()` will not clear any results set up for the substitute using `Returns()`. If we need to this, we can [replace previously specified results](/help/replacing-return-values) by calling `Returns()` again.

docs/help/_posts/2010-04-01-argument-matchers.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,4 @@ public void ManualArgSnapshot() {
293293
}
294294
```
295295

296-
We can then use our standard assertion library for checking the value. This approach can also be helpful for asserting on complex objects, as our assertions can be more detailed and provide more useful information than NSubstitute typically provides in these cases.
296+
We can then use our standard assertion library for checking the value. This approach can also be helpful for asserting on complex objects, as our assertions can be more detailed and provide more useful information than NSubstitute typically provides in these cases.

docs/help/_posts/2010-05-01-callbacks.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,4 @@ for (int i = 0; i < 5; i++)
111111
}
112112
Assert.That(String.Concat(calls), Is.EqualTo("123++"));
113113
Assert.That(counter, Is.EqualTo(5));
114-
```
115-
114+
```

docs/help/_posts/2010-05-02-throwing-exceptions.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ calculator
2525
//Both calls will now throw.
2626
Assert.Throws<Exception>(() => calculator.Add(-1, -1));
2727
Assert.Throws<Exception>(() => calculator.Add(-2, -2));
28-
```
29-
28+
```

docs/help/_posts/2010-05-10-configure.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Assert.Throws<Exception>(() => calculator.Add(-2, -2));
3232

3333
NSubstitute will also assume we are configuring a call if we have an argument matcher in our call, such as `Arg.Is(1)` in `calculator.Add(Arg.Is(1), 2).Returns(3)`, but it is generally better to be more explicit by using `.Configure()`.
3434

35-
This can be particularly useful with [partial substitutes](/help/partial-subs/) to help avoid real code being executed when configuring calls that would otherwise call the base implementation.
35+
This can be particularly useful with [partial substitutes](/help/partial-subs/) to help avoid real code being executed when configuring calls that would otherwise call the base implementation.

docs/help/_posts/2010-06-01-raising-events.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ engine.RevvedAt += rpm => revvedAt = rpm;
9595
engine.RevvedAt += Raise.Event<Action<int>>(123);
9696

9797
Assert.AreEqual(123, revvedAt);
98-
```
98+
```

docs/help/_posts/2010-10-01-auto-and-recursive-mocks.markdown

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,4 @@ Properties and methods returning types of `String` or `Array` will automatically
103103
var identity = Substitute.For<IIdentity>();
104104
Assert.AreEqual(String.Empty, identity.Name);
105105
Assert.AreEqual(0, identity.Roles().Length);
106-
```
107-
108-
109-
110-
111-
106+
```

docs/help/_posts/2010-11-01-setting-out-and-ref-arguments.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ Assert.AreEqual(1, counter);
5656
lookup.TryLookup("hello", out value);
5757
// Call does NOT match anymore, counter is still 1:
5858
Assert.AreEqual(1, counter);
59-
```
60-
59+
```

docs/help/_posts/2010-12-01-actions-with-arguments.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,4 @@ var results = new[] {
127127

128128
Assert.AreEqual(3, numberOfCallsWhereFirstArgIsLessThan0); //3 of 4 calls have first arg < 0
129129
Assert.AreEqual(results, new[] {123, 123, 123, 0}); //Last call returns 0, not 123
130-
```
131-
130+
```

docs/help/_posts/2013-01-01-received-in-order.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,4 @@ public interface ICommand {
6565
void Run(IConnection c);
6666
}
6767
```
68-
-->
69-
68+
-->

docs/help/_posts/2013-02-01-partial-subs.markdown

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,4 @@ public void ShouldSendMultipleEmails() {
7777

7878
## Test spies
7979

80-
Even without substituting for specific parts of a class, the instance returned by `Substitute.ForPartsOf<T>` records all calls made to virtual members, so we can [check `Received()` calls](/help/received-calls/) made to any partial substitute.
81-
82-
80+
Even without substituting for specific parts of a class, the instance returned by `Substitute.ForPartsOf<T>` records all calls made to virtual members, so we can [check `Received()` calls](/help/received-calls/) made to any partial substitute.

docs/help/_posts/2013-03-01-return-for-all.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ public void ReturnsTakesPrecedence() {
8484
Assert.That(sub.GetWidget(1), Is.SameAs(widget));
8585
Assert.That(sub.GetWidget(42), Is.SameAs(otherWidget));
8686
}
87-
```
87+
```

docs/help/_posts/2013-04-01-threading.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ It is fairly standard for production code to call a substitute from multiple thr
77

88
Although this particular issue has been mitigated by work in [#452](https://github.com/nsubstitute/NSubstitute/pull/462), issue [#256](https://github.com/nsubstitute/NSubstitute/issues/256) shows the types of problems that can occur if we're not careful with threading.
99

10-
To avoid this sort of problem, make sure your test has finished configuring its substitutes before exercising the production code, then make sure the production code has completed before your test asserts on `Received()` calls.
11-
10+
To avoid this sort of problem, make sure your test has finished configuring its substitutes before exercising the production code, then make sure the production code has completed before your test asserts on `Received()` calls.

docs/help/_posts/2013-04-15-compat-args.markdown

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,4 @@ public void Sample() {
115115
// Or re-write without expression tree if possible:
116116
sub.Received().DoStuff(Arg.Any<int>());
117117
}
118-
```
119-
120-
118+
```

docs/help/_posts/2013-05-01-nsubstitute-analysers.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ See [NSubstitute.Analyzers documentation](https://github.com/nsubstitute/NSubsti
1818

1919
## Spelling
2020

21-
The Australian members of our team would like to point out they would have preferred to use the English spelling `NSubstitute.Analysers` for this project, but have begrudgingly agreed to use the American (mis)spelling instead. :)
21+
The Australian members of our team would like to point out they would have preferred to use the English spelling `NSubstitute.Analysers` for this project, but have begrudgingly agreed to use the American (mis)spelling instead. :)

docs/help/_posts/2015-01-01-how-nsub-works.markdown

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,4 @@ The final thing to notice here is that there is the potential for real logic fro
8686
* Be careful substituting for classes!
8787
* Where possible use interfaces instead.
8888
* Remember NSubstitute works by inheriting from (or implementing) your original type. If you can't override a member by manually writing a sub-class, then NSubstitute won't be able to either!
89-
* Install [NSubstitute.Analyzers](/help/nsubstitute-analysers) where ever you install NSubstitute. This will help you avoid these (and other) pitfalls.
90-
91-
89+
* Install [NSubstitute.Analyzers](/help/nsubstitute-analysers) where ever you install NSubstitute. This will help you avoid these (and other) pitfalls.

docs/index.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ title: A friendly substitute for .NET mocking libraries
55

66
<div id="features">
77
<div class="feature" markdown="1">
8-
<h2>Simple, succinct, pleasant to use</h2>
8+
9+
## Simple, succinct, pleasant to use
910

1011
```csharp
1112
//Create:
@@ -35,8 +36,10 @@ calculator.PoweringUp += Raise.Event();
3536
-->
3637
</div>
3738

38-
<div class="feature">
39-
<h2>Helpful exceptions</h2>
39+
<div class="feature" markdown="1">
40+
41+
## Helpful exceptions
42+
4043
<div class="highlight">
4144
<pre>
4245
ReceivedCallsException : Expected to receive a call matching:
@@ -48,8 +51,10 @@ Received 2 non-matching calls (non-matching arguments indicated with '*' charact
4851
</div>
4952
</div>
5053

51-
<div class="feature">
52-
<h2>Don't sweat the small stuff</h2>
54+
<div class="feature" markdown="1">
55+
56+
## Don't sweat the small stuff
57+
5358
<p>Mock, stub, fake, spy, test double? Strict or loose? Nah, just substitute for the type you need!</p>
5459
<p>NSubstitute is designed for Arrange-Act-Assert (AAA) testing, so you just need to arrange how it should work, then assert it received the calls you expected once you're done. Because you've got more important code to write than whether you need a mock or a stub.</p>
5560
</div>
@@ -74,8 +79,9 @@ Received 2 non-matching calls (non-matching arguments indicated with '*' charact
7479
</div>
7580

7681
<div class="sidebar">
77-
<div id="why-use-it">
78-
<h3>Another library?</h3>
82+
<div id="why-use-it" markdown="1">
83+
84+
### Another library?
7985

8086
<p>There are already some great mocking libraries around for .NET, so why create another? We found that for all their great features, none of the existing libraries had the succinct syntax we were craving &mdash; the code required to configure test doubles quickly obscured the intention behind our tests.</p>
8187

0 commit comments

Comments
 (0)