Skip to content

Commit ca14c36

Browse files
authored
[docs] Fix syntax highlighting issues to support newer Sphinxes. (swiftlang#4283)
- Update the Pygments lexer we use for parsing Swift-like code. - State more explicitly which highlighting should be used in which code blocks. - Disable highlighting altogether in certain cases (such as SIL.rst, which has equal amounts grammar and SIL excerpts). This should fix the warnings-as-error issues coming from Sphinx > 1.3.4. Based on a patch by Jeremy Fergason! https://bugs.swift.org/browse/SR-620
1 parent b906a25 commit ca14c36

18 files changed

+161
-61
lines changed

docs/ABI.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
.. @raise litre.TestsAreMissing
44
.. _ABI:
55

6+
.. highlight:: none
7+
68
The Swift ABI
79
=============
810

docs/ARCOptimization.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
:orphan:
22

3+
.. highlight:: sil
4+
35
==========================
46
ARC Optimization for Swift
57
==========================

docs/DebuggingTheCompiler.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
:orphan:
22

3+
.. highlight:: none
4+
35
Debugging the Swift Compiler
46
============================
57

docs/DriverParseableOutput.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Parseable Driver Output
55
.. contents::
66
:local:
77

8+
.. highlight:: none
9+
810
Introduction
911
============
1012

docs/ErrorHandlingRationale.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,19 @@ generally needs as much code in the function as implicit manual
879879
propagation would. However, we could optimize this for many common
880880
cases by causing clean-ups to be called automatically by the
881881
interpretation function. That is, instead of a landing pad that looks
882-
notionally like this::
882+
notionally like this:
883883
884-
void *exception = ...;
884+
.. code-block:: objc++
885+
886+
void *exception = /*...*/;
885887
SomeCXXType::~SomeCXXType(&foo);
886888
objc_release(bar);
887889
objc_release(baz);
888890
_Unwind_Resume(exception);
889891
890-
The unwind table would have a record that looks notionally like this::
892+
The unwind table would have a record that looks notionally like this:
893+
894+
.. code-block:: objc++
891895
892896
CALL_WITH_FRAME_ADDRESS(&SomeCXXType::~SomeCXXType, FRAME_OFFSET_OF(foo))
893897
CALL_WITH_FRAME_VALUE(&objc_release, FRAME_OFFSET_OF(bar))

docs/GitWorkflows.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
:orphan:
22

3+
.. highlight:: bash
4+
35
Git Workflows
46
=============
57

docs/LibraryEvolution.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ specifying the name of the client library along with the required version::
121121

122122
// Client code
123123
@available(Magician 1.5)
124-
class CrystalBallView : MagicView { }
124+
class CrystalBallView : MagicView { /*…*/ }
125125

126126
Library versions can also be checked dynamically using ``#available``, allowing
127127
for fallback behavior when the requested library version is not present::
@@ -351,7 +351,7 @@ example using methods::
351351

352352
public struct Point2D {
353353
var x, y: Double
354-
public init(x: Double, y: Double) { }
354+
public init(x: Double, y: Double) { /*…*/ }
355355
}
356356

357357
extension Point2D {
@@ -368,7 +368,7 @@ polar representation::
368368

369369
public struct Point2D {
370370
var r, theta: Double
371-
public init(x: Double, y: Double) { }
371+
public init(x: Double, y: Double) { /*…*/ }
372372
}
373373

374374
and the ``x`` and ``y`` properties have now disappeared. To avoid this, the
@@ -693,13 +693,13 @@ can enforce its safe use.
693693
We've considered two possible syntaxes for this::
694694

695695
@available(1.1)
696-
extension Wand : MagicType {}
696+
extension Wand : MagicType {/*…*/}
697697

698698
and
699699

700700
::
701701

702-
extension Wand : @available(1.1) MagicType {}
702+
extension Wand : @available(1.1) MagicType {/*…*/}
703703

704704
The former requires fewer changes to the language grammar, but the latter could
705705
also be used on the declaration of the type itself (i.e. the ``struct``

docs/MutationModel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ What do we do with this? Since ``+=`` has an ``inout`` first
4444
argument, we detect this situation statically (hopefully one day we'll
4545
have a better error message):
4646

47-
::
47+
.. code-block:: swift-console
4848
4949
<REPL Input>:1:9: error: expression does not type-check
5050
w.title += " (parenthesized remark)"

docs/PatternMatching.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,20 @@ braces end up causing a lot of unnecessary vertical whitespace, like so::
292292

293293
switch (x)
294294
case .foo {
295-
295+
//
296296
}
297297
case .bar {
298-
298+
//
299299
}
300300
301301
So instead, let's require the switch statement to have braces, and
302302
we'll allow the cases to be written without them::
303303

304304
switch (x) {
305305
case .foo:
306-
306+
//
307307
case .bar:
308-
308+
//
309309
}
310310

311311
That's really a lot prettier, except it breaks the rule about always grouping

docs/SIL.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. @raise litre.TestsAreMissing
2+
.. highlight:: none
23

34
Swift Intermediate Language (SIL)
45
=================================

0 commit comments

Comments
 (0)