Skip to content

Commit 28aed3f

Browse files
authored
[Docs] Show opening tags. (#5723)
* No need to carry the :lines: directive around anymore. * Display php opening tag. * Add closing tag for mixed HTML. * Remove unneeded comment. * Convert comment. * Convert comment to HTML.
1 parent ddb1400 commit 28aed3f

File tree

123 files changed

+58
-1360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+58
-1360
lines changed

user_guide_src/renumerate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ foreach ($srcIterator as $chapterInfo) {
3939
$sectionContent = file_get_contents($sectionInfo->getPathname());
4040

4141
// Match all includes
42-
preg_match_all("~\\.\\. literalinclude:: {$sectionName}\\/(.+)\\.php(\n[ ]*:lines: 2\\-)?~", $sectionContent, $matches);
42+
preg_match_all("~\\.\\. literalinclude:: {$sectionName}\\/(.+)\\.php~", $sectionContent, $matches);
4343
$includeStrings = $matches[0];
4444
$exampleNames = $matches[1];
4545

user_guide_src/source/cli/cli.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ the CLI as easily as you would create any other route. Instead of using the ``ge
8585
works exactly like a normal route definition:
8686

8787
.. literalinclude:: cli/002.php
88-
:lines: 2-
8988

9089
For more information, see the :ref:`Routes <command-line-only-routes>` page.
9190

user_guide_src/source/cli/cli_commands.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Commands can also be ran from within your own code. This is most often done with
4848
but they can be used at any time. You do this by using the ``command()`` function. This function is always available.
4949

5050
.. literalinclude:: cli_commands/001.php
51-
:lines: 2-
5251

5352
The only argument is string that is the command called and any parameters. This appears exactly as you would call
5453
it from the command line.
@@ -127,15 +126,13 @@ any CLI arguments after the command name for your use. If the CLI string was::
127126
Then **foo** is the command name, and the ``$params`` array would be:
128127

129128
.. literalinclude:: cli_commands/003.php
130-
:lines: 2-
131129

132130
This can also be accessed through the :doc:`CLI </cli/cli_library>` library, but this already has your command removed
133131
from the string. These parameters can be used to customize how your scripts behave.
134132

135133
Our demo command might have a ``run`` method something like:
136134

137135
.. literalinclude:: cli_commands/004.php
138-
:lines: 2-
139136

140137
***********
141138
BaseCommand
@@ -155,7 +152,6 @@ be familiar with when creating your own commands. It also has a :doc:`Logger </g
155152
This method allows you to run other commands during the execution of your current command:
156153

157154
.. literalinclude:: cli_commands/005.php
158-
:lines: 2-
159155

160156
.. php:method:: showError(Throwable $e)
161157
@@ -164,7 +160,6 @@ be familiar with when creating your own commands. It also has a :doc:`Logger </g
164160
A convenience method to maintain a consistent and clear error output to the CLI:
165161

166162
.. literalinclude:: cli_commands/006.php
167-
:lines: 2-
168163

169164
.. php:method:: showHelp()
170165
@@ -178,4 +173,3 @@ be familiar with when creating your own commands. It also has a :doc:`Logger </g
178173
A method to calculate padding for $key => $value array output. The padding can be used to output a will formatted table in CLI:
179174

180175
.. literalinclude:: cli_commands/007.php
181-
:lines: 2-

user_guide_src/source/cli/cli_library.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,34 @@ handled with the ``prompt()`` or ``promptByKey()`` method.
3434
You can provide a question by passing it in as the first parameter:
3535

3636
.. literalinclude:: cli_library/002.php
37-
:lines: 2-
3837

3938
You can provide a default answer that will be used if the user just hits enter by passing the default in the
4039
second parameter:
4140

4241
.. literalinclude:: cli_library/003.php
43-
:lines: 2-
4442

4543
You can restrict the acceptable answers by passing in an array of allowed answers as the second parameter:
4644

4745
.. literalinclude:: cli_library/004.php
48-
:lines: 2-
4946

5047
Finally, you can pass :ref:`validation <validation>` rules to the answer input as the third parameter:
5148

5249
.. literalinclude:: cli_library/005.php
53-
:lines: 2-
5450

5551
Validation rules can also be written in the array syntax:
5652

5753
.. literalinclude:: cli_library/006.php
58-
:lines: 2-
5954

6055
**promptByKey()**
6156

6257
Predefined answers (options) for prompt sometimes need to be described or are too complex to select via their value.
6358
``promptByKey()`` allows the user to select an option by its key instead of its value:
6459

6560
.. literalinclude:: cli_library/007.php
66-
:lines: 2-
6761

6862
Named keys are also possible:
6963

7064
.. literalinclude:: cli_library/008.php
71-
:lines: 2-
7265

7366
Finally, you can pass :ref:`validation <validation>` rules to the answer input as the third parameter, the acceptable answers are automatically restricted to the passed options.
7467

@@ -82,18 +75,15 @@ or a complex table of information that wraps to the user's terminal window. At t
8275
method which takes the string to output as the first parameter:
8376

8477
.. literalinclude:: cli_library/009.php
85-
:lines: 2-
8678

8779
You can change the color of the text by passing in a color name as the second parameter:
8880

8981
.. literalinclude:: cli_library/010.php
90-
:lines: 2-
9182

9283
This could be used to differentiate messages by status, or create 'headers' by using a different color. You can
9384
even set background colors by passing the color name in as the third parameter:
9485

9586
.. literalinclude:: cli_library/011.php
96-
:lines: 2-
9787

9888
The following foreground colors are available:
9989

@@ -134,7 +124,6 @@ the same line, from different calls. This is especially helpful when you want to
134124
print "Done" on the same line:
135125

136126
.. literalinclude:: cli_library/012.php
137-
:lines: 2-
138127

139128
**color()**
140129

@@ -144,7 +133,6 @@ an EOL after printing. This allows you to create multiple outputs on the same ro
144133
it inside of a ``write()`` method to create a string of a different color inside:
145134

146135
.. literalinclude:: cli_library/013.php
147-
:lines: 2-
148136

149137
This example would write a single line to the window, with ``fileA`` in yellow, followed by a tab, and then
150138
``/path/to/file`` in white text.
@@ -157,7 +145,6 @@ for errors so they don't have to sift through all of the information, only the a
157145
exactly as you would the ``write()`` method:
158146

159147
.. literalinclude:: cli_library/014.php
160-
:lines: 2-
161148

162149
**wrap()**
163150

@@ -166,23 +153,20 @@ This might be useful when displaying a list of options with descriptions that yo
166153
window and not go off screen:
167154

168155
.. literalinclude:: cli_library/015.php
169-
:lines: 2-
170156

171157
By default, the string will wrap at the terminal width. Windows currently doesn't provide a way to determine
172158
the window size, so we default to 80 characters. If you want to restrict the width to something shorter that
173159
you can be pretty sure fits within the window, pass the maximum line-length as the second parameter. This
174160
will break the string at the nearest word barrier so that words are not broken.
175161

176162
.. literalinclude:: cli_library/016.php
177-
:lines: 2-
178163

179164
You may find that you want a column on the left of titles, files, or tasks, while you want a column of text
180165
on the right with their descriptions. By default, this will wrap back to the left edge of the window, which
181166
doesn't allow things to line up in columns. In cases like this, you can pass in a number of spaces to pad
182167
every line after the first line, so that you will have a crisp column edge on the left:
183168

184169
.. literalinclude:: cli_library/017.php
185-
:lines: 2-
186170

187171
Would create something like this:
188172

@@ -200,7 +184,6 @@ Would create something like this:
200184
The ``newLine()`` method displays a blank line to the user. It does not take any parameters:
201185

202186
.. literalinclude:: cli_library/018.php
203-
:lines: 2-
204187

205188
**clearScreen()**
206189

@@ -209,7 +192,6 @@ simply insert 40 blank lines since Windows doesn't support this feature. Windows
209192
this:
210193

211194
.. literalinclude:: cli_library/019.php
212-
:lines: 2-
213195

214196
**showProgress()**
215197

@@ -227,12 +209,10 @@ The percent complete and the length of the display will be determined based on t
227209
pass ``false`` as the first parameter and the progress bar will be removed.
228210

229211
.. literalinclude:: cli_library/020.php
230-
:lines: 2-
231212

232213
**table()**
233214

234215
.. literalinclude:: cli_library/021.php
235-
:lines: 2-
236216

237217
.. code-block:: none
238218
@@ -249,4 +229,3 @@ Waits a certain number of seconds, optionally showing a wait message and
249229
waiting for a key press.
250230

251231
.. literalinclude:: cli_library/022.php
252-
:lines: 2-

user_guide_src/source/cli/cli_request.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,31 @@ Additional Accessors
1515
Returns an array of the command line arguments deemed to be part of a path:
1616

1717
.. literalinclude:: cli_request/001.php
18-
:lines: 2-
1918

2019
**getPath()**
2120

2221
Returns the reconstructed path as a string:
2322

2423
.. literalinclude:: cli_request/002.php
25-
:lines: 2-
2624

2725
**getOptions()**
2826

2927
Returns an array of the command line arguments deemed to be options:
3028

3129
.. literalinclude:: cli_request/003.php
32-
:lines: 2-
3330

3431
**getOption($which)**
3532

3633
Returns the value of a specific command line argument deemed to be an option:
3734

3835
.. literalinclude:: cli_request/004.php
39-
:lines: 2-
4036

4137
**getOptionString()**
4238

4339
Returns the reconstructed command line string for the options:
4440

4541
.. literalinclude:: cli_request/005.php
46-
:lines: 2-
4742

4843
Passing ``true`` to the first argument will try to write long options using two dashes:
4944

5045
.. literalinclude:: cli_request/006.php
51-
:lines: 2-

user_guide_src/source/concepts/autoloader.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ etc. The ``psr4`` array in the configuration file allows you to map the namespac
4040
those classes can be found in:
4141

4242
.. literalinclude:: autoloader/001.php
43-
:lines: 2-
4443

4544
The key of each row is the namespace itself. This does not need a trailing slash. If you use double-quotes
4645
to define the array, be sure to escape the backward slash. That means that it would be ``My\\App``,
@@ -53,7 +52,6 @@ You may change this namespace by editing the **/app/Config/Constants.php** file
5352
new namespace value under the ``APP_NAMESPACE`` setting:
5453

5554
.. literalinclude:: autoloader/002.php
56-
:lines: 2-
5755

5856
You will need to modify any existing files that are referencing the current namespace.
5957

@@ -69,7 +67,6 @@ by not hitting the file-system with extra ``is_file()`` calls. You can use the c
6967
third-party libraries that are not namespaced:
7068

7169
.. literalinclude:: autoloader/003.php
72-
:lines: 2-
7370

7471
The key of each row is the name of the class that you want to locate. The value is the path to locate it at.
7572

user_guide_src/source/concepts/factories.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ the common path structure for namespaces and folders, Factories know that the mo
2525
and classes are found within **Models**, so you can request a model by its shorthand base name:
2626

2727
.. literalinclude:: factories/001.php
28-
:lines: 2-
2928

3029
Or you could also request a specific class:
3130

3231
.. literalinclude:: factories/002.php
33-
:lines: 2-
3432

3533
Next time you ask for the same class anywhere in your code, ``Factories`` will be sure
3634
you get back the instance as before:
3735

3836
.. literalinclude:: factories/003.php
39-
:lines: 2-
4037

4138
Factory Parameters
4239
==================
@@ -50,7 +47,6 @@ your app uses a separate database for authentication and you want to be sure tha
5047
to access user records always go through that connection:
5148

5249
.. literalinclude:: factories/004.php
53-
:lines: 2-
5450

5551
Now any time the ``UserModel`` is loaded from ``Factories`` it will in fact be returning a
5652
class instance that uses the alternate database connection.
@@ -108,7 +104,6 @@ supply the desired array of options using the ``setOptions()`` method and they w
108104
merged with the default values and stored for the next call:
109105

110106
.. literalinclude:: factories/006.php
111-
:lines: 2-
112107

113108
Parameter Options
114109
-----------------

user_guide_src/source/concepts/http.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ abstracts them so that you have a consistent, simple interface to them. The :doc
7171
is an object-oriented representation of the HTTP request. It provides everything you need:
7272

7373
.. literalinclude:: http/001.php
74-
:lines: 2-
7574

7675
The request class does a lot of work in the background for you, that you never need to worry about.
7776
The ``isAJAX()`` and ``isSecure()`` methods check several different methods to determine the correct answer.
@@ -82,6 +81,5 @@ CodeIgniter also provides a :doc:`Response class </outgoing/response>` that is a
8281
of the HTTP response. This gives you an easy and powerful way to construct your response to the client:
8382

8483
.. literalinclude:: http/002.php
85-
:lines: 2-
8684

8785
In addition, the Response class allows you to work the HTTP cache layer for the best performance.

user_guide_src/source/concepts/services.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ A quick example will probably make things clearer, so imagine that you need to p
1717
of the Timer class. The simplest method would simply be to create a new instance of that class:
1818

1919
.. literalinclude:: services/001.php
20-
:lines: 2-
2120

2221
And this works great. Until you decide that you want to use a different timer class in its place.
2322
Maybe this one has some advanced reporting the default timer does not provide. In order to do this,
@@ -32,7 +31,6 @@ to use as a service. The method typically returns a shared instance of that clas
3231
it might have into it. Then, we would replace our timer creation code with code that calls this new class:
3332

3433
.. literalinclude:: services/002.php
35-
:lines: 2-
3634

3735
When you need to change the implementation used, you can modify the services configuration file, and
3836
the change happens automatically throughout your application without you having to do anything. Now
@@ -52,18 +50,15 @@ file always returns a SHARED instance of the class, so calling the function mult
5250
always return the same instance:
5351

5452
.. literalinclude:: services/003.php
55-
:lines: 2-
5653

5754
If the creation method requires additional parameters, they can be passed after the service name:
5855

5956
.. literalinclude:: services/004.php
60-
:lines: 2-
6157

6258
The second function, ``single_service()`` works just like ``service()`` but returns a new instance of
6359
the class:
6460

6561
.. literalinclude:: services/005.php
66-
:lines: 2-
6762

6863
Defining Services
6964
=================
@@ -79,13 +74,11 @@ want to create a replacement that provides a different way to create routes, you
7974
create a new class that implements the ``RouterCollectionInterface``:
8075

8176
.. literalinclude:: services/006.php
82-
:lines: 2-
8377

8478
Finally, modify **/app/Config/Services.php** to create a new instance of ``MyRouter``
8579
instead of ``CodeIgniter\Router\RouterCollection``:
8680

8781
.. literalinclude:: services/007.php
88-
:lines: 2-
8982

9083
Allowing Parameters
9184
-------------------
@@ -99,13 +92,11 @@ changing that path, though, if their needs require it. So the class accepts the
9992
as a constructor parameter. The service method looks like this:
10093

10194
.. literalinclude:: services/008.php
102-
:lines: 2-
10395

10496
This sets the default path in the constructor method, but allows for easily changing
10597
the path it uses:
10698

10799
.. literalinclude:: services/009.php
108-
:lines: 2-
109100

110101
Shared Classes
111102
-----------------
@@ -117,7 +108,6 @@ within the class, and, if not, creates a new one. All of the factory methods pro
117108
``$getShared = true`` value as the last parameter. You should stick to the method also:
118109

119110
.. literalinclude:: services/010.php
120-
:lines: 2-
121111

122112
Service Discovery
123113
-----------------
@@ -142,6 +132,5 @@ Now you can use this file as described above. When you want to grab the posts se
142132
would simply use the framework's ``Config\Services`` class to grab your service:
143133

144134
.. literalinclude:: services/012.php
145-
:lines: 2-
146135

147136
.. note:: If multiple Services files have the same method name, the first one found will be the instance returned.

0 commit comments

Comments
 (0)