]>
Commit | Line | Data |
---|---|---|
9de103f0 QY |
1 | .. _process-and-workflow: |
2 | ||
3 | ******************* | |
b22ba015 | 4 | Process & Workflow |
9de103f0 | 5 | ******************* |
d1890d04 | 6 | |
b6820993 QY |
7 | .. highlight:: none |
8 | ||
b22ba015 QY |
9 | FRR is a large project developed by many different groups. This section |
10 | documents standards for code style & quality, commit messages, pull requests | |
11 | and best practices that all contributors are asked to follow. | |
d1890d04 | 12 | |
9de103f0 QY |
13 | This chapter is "descriptive/post-factual" in that it documents pratices that |
14 | are in use; it is not "definitive/pre-factual" in prescribing practices. This | |
b22ba015 QY |
15 | means that when a procedure changes, it is agreed upon, then put into practice, |
16 | and then documented here. If this document doesn't match reality, it's the | |
17 | document that needs to be updated, not reality. | |
d1890d04 | 18 | |
9de103f0 QY |
19 | Mailing Lists |
20 | ============= | |
d1890d04 | 21 | |
b22ba015 QY |
22 | The FRR development group maintains multiple mailing lists for use by the |
23 | community. Italicized lists are private. | |
d1890d04 QY |
24 | |
25 | +----------------------------------+--------------------------------+ | |
26 | | Topic | List | | |
27 | +==================================+================================+ | |
28 | | Development | dev@lists.frrouting.org | | |
29 | +----------------------------------+--------------------------------+ | |
30 | | Users & Operators | frog@lists.frrouting.org | | |
31 | +----------------------------------+--------------------------------+ | |
32 | | Announcements | announce@lists.frrouting.org | | |
33 | +----------------------------------+--------------------------------+ | |
34 | | *Security* | security@lists.frrouting.org | | |
35 | +----------------------------------+--------------------------------+ | |
36 | | *Technical Steering Committee* | tsc@lists.frrouting.org | | |
37 | +----------------------------------+--------------------------------+ | |
38 | ||
9de103f0 | 39 | The Development list is used to discuss and document general issues related to |
b6820993 QY |
40 | project development and governance. The public |
41 | `Slack instance <https://frrouting.slack.com>`_ and weekly technical meetings | |
42 | provide a higher bandwidth channel for discussions. The results of such | |
43 | discussions must be reflected in updates, as appropriate, to code (i.e., | |
44 | merges), `GitHub issues`_, and for governance or process changes, updates to | |
45 | the Development list and either this file or information posted at | |
46 | https://frrouting.org/. | |
47 | ||
48 | Development & Release Cycle | |
49 | =========================== | |
50 | ||
51 | Development | |
52 | ----------- | |
53 | ||
54 | .. figure:: ../figures/git_branches.png | |
55 | :align: center | |
56 | :scale: 55% | |
57 | :alt: Merging Git branches into a central trunk | |
58 | ||
59 | Rough outline of FRR development workflow | |
60 | ||
61 | The master Git for FRR resides on `GitHub`_. | |
62 | ||
63 | There is one main branch for development, ``master``. For each major release | |
64 | (2.0, 3.0 etc) a new release branch is created based on the master. Significant | |
65 | bugfixes should be backported to upcoming and existing release branches no more | |
66 | than 1 year old. As a general rule new features are not backported to release | |
67 | branches. | |
8ce7861f | 68 | |
b6820993 | 69 | Subsequent point releases based on a major branch are handled with git tags. |
c804874a | 70 | |
b6820993 QY |
71 | Releases |
72 | -------- | |
73 | FRR employs a ``<MAJOR>.<MINOR>.<BUGFIX>`` versioning scheme. | |
c804874a | 74 | |
b6820993 | 75 | ``MAJOR`` |
c804874a QY |
76 | Significant new features or multiple minor features. The addition of a new |
77 | routing protocol or daemon would fall under this class. | |
78 | ||
b6820993 | 79 | ``MINOR`` |
c804874a QY |
80 | Small features, e.g. options for automatic BGP shutdown. |
81 | ||
b6820993 | 82 | ``BUGFIX`` |
c804874a QY |
83 | Fixes for actual bugs and/or security issues. |
84 | ||
85 | We will pull a new development branch for the next release every 4 months. The | |
b6820993 QY |
86 | current schedule is Feb/June/October 1. The decision for a ``MAJOR/MINOR`` |
87 | release is made at the time of branch pull based on what has been received the | |
88 | previous 4 months. The branch name will be ``dev/MAJOR.MINOR``. At this point | |
89 | in time the master branch and this new branch, :file:`configure.ac`, | |
90 | documentation and packaging systems will be updated to reflect the next | |
91 | possible release name to allow for easy distinguishing. | |
92 | ||
93 | After one month the development branch will be renamed to | |
bd2b4fc3 PG |
94 | ``stable/MAJOR.MINOR``. The branch is a stable branch. This process is not |
95 | held up unless a crash or security issue has been found and needs to | |
96 | be addressed. Issues being fixed will not cause a delay. | |
c804874a QY |
97 | |
98 | Bugfix releases are made as needed at 1 month intervals until the next | |
bd2b4fc3 | 99 | ``MAJOR.MINOR`` release branch is pulled. Depending on the severity of the bugs, |
c804874a QY |
100 | bugfix releases may occur sooner. |
101 | ||
102 | Bugfixes are applied to the two most recent releases. Security fixes are | |
bd2b4fc3 PG |
103 | backported to all releases less than or equal to at least one year old. Security |
104 | fixes may also be backported to older releases depending on severity. | |
105 | ||
106 | Long term support branches ( LTS ) | |
107 | ----------------------------------------- | |
108 | ||
109 | This kind of branch is not yet officially supported, and need experimentation | |
110 | before being effective. | |
111 | ||
112 | Previous definition of releases prevents long term support of previous releases. | |
113 | For instance, bug and security fixes are not applied if the stable branch is too | |
114 | old. | |
115 | ||
116 | Because the FRR users have a need to backport bug and security fixes after the | |
117 | stable branch becomes too old, there is a need to provide support on a long term | |
118 | basis on that stable branch. If that support is applied on that stable branch, | |
119 | then that branch is a long term support branch. | |
120 | ||
121 | Having a LTS branch requires extra-work and requires one person to be in charge | |
122 | of that maintenance branch for a certain amount of time. The amount of time will | |
123 | be by default set to 4 months, and can be increased. 4 months stands for the time | |
124 | between two releases, this time can be applied to the decision to continue with a | |
125 | LTS release or not. In all cases, that time period will be well-defined and | |
126 | published. Also, a self nomination from a person that proposes to handle the LTS | |
127 | branch is required. The work can be shared by multiple people. In all cases, there | |
128 | must be at least one person that is in charge of the maintenance branch. The person | |
129 | on people responsible for a maintenance branch must be a FRR maintainer. Note that | |
130 | they may choose to abandon support for the maintenance branch at any time. If | |
131 | noone takes over the responsibility of the LTS branch, then the support will be | |
132 | discontinued. | |
133 | ||
134 | The LTS branch duties are the following ones: | |
135 | ||
136 | - organise meetings on a (bi-)weekly or monthly basis, the handling of issues | |
137 | and pull requested relative to that branch. When time permits, this may be done | |
138 | during the regularly scheduled FRR meeting. | |
139 | ||
140 | - ensure the stability of the branch, by using and eventually adapting the | |
141 | checking the CI tools of FRR ( indeed, maintaining may lead to create | |
142 | maintenance branches for topotests or for CI). | |
143 | ||
144 | It will not be possible to backport feature requests to LTS branches. Actually, it | |
145 | is a false good idea to use LTS for that need. Introducing feature requests may | |
146 | break the paradigm where all more recent releases should also include the feature | |
147 | request. This would require the LTS maintainer to ensure that all more recent | |
148 | releases have support for this feature request. Moreover, introducing features | |
149 | requests may result in breaking the stability of the branch. LTS branches are first | |
150 | done to bring long term support for stability. | |
8ce7861f | 151 | |
d1890d04 | 152 | Changelog |
b6820993 | 153 | --------- |
b22ba015 QY |
154 | The changelog will be the base for the release notes. A changelog entry for |
155 | your changes is usually not required and will be added based on your commit | |
156 | messages by the maintainers. However, you are free to include an update to the | |
157 | changelog with some better description. | |
d1890d04 QY |
158 | |
159 | Submitting Patches and Enhancements | |
9de103f0 | 160 | =================================== |
d1890d04 | 161 | |
b22ba015 QY |
162 | FRR accepts patches from two sources: |
163 | ||
164 | - Email (git format-patch) | |
b6820993 | 165 | - GitHub pull request |
b22ba015 | 166 | |
b6820993 QY |
167 | Contributors are highly encouraged to use GitHub's fork-and-PR workflow. It is |
168 | easier for us to review it, test it, try it and discuss it on GitHub than it is | |
169 | via email, thus your patch will get more attention more quickly on GitHub. | |
b22ba015 QY |
170 | |
171 | The base branch for new contributions and non-critical bug fixes should be | |
172 | ``master``. Please ensure your pull request is based on this branch when you | |
173 | submit it. | |
174 | ||
b6820993 QY |
175 | GitHub Pull Requests |
176 | -------------------- | |
d1890d04 | 177 | |
b6820993 QY |
178 | The preferred method of submitting changes is a GitHub pull request. Code |
179 | submitted by pull request will be automatically tested by one or more CI | |
180 | systems. Once the automated tests succeed, other developers will review your | |
181 | code for quality and correctness. After any concerns are resolved, your code | |
182 | will be merged into the branch it was submitted against. | |
d1890d04 | 183 | |
01bf2ccb LB |
184 | The title of the pull request should provide a high level technical |
185 | summary of the included patches. The description should provide | |
186 | additional details that will help the reviewer to understand the context | |
187 | of the included patches. | |
188 | ||
b6820993 QY |
189 | Patch Submission via Mailing List |
190 | --------------------------------- | |
d1890d04 | 191 | |
b6820993 QY |
192 | As an alternative submission method, a patch can be mailed to the |
193 | development mailing list. Patches received on the mailing list will be | |
194 | picked up by Patchwork and tested against the latest development branch. | |
d1890d04 | 195 | |
b6820993 QY |
196 | The recommended way to send the patch (or series of NN patches) to the |
197 | list is by using ``git send-email`` as follows (assuming they are the N | |
198 | most recent commit(s) in your git history):: | |
d1890d04 | 199 | |
b6820993 | 200 | git send-email -NN --annotate --to=dev@lists.frrouting.org |
d1890d04 | 201 | |
b6820993 QY |
202 | If your commits do not already contain a ``Signed-off-by`` line, then |
203 | use the following command to add it (after making sure you agree to the | |
204 | Developer Certificate of Origin as outlined above):: | |
d1890d04 | 205 | |
b6820993 | 206 | git send-email -NN --annotate --signoff --to=dev@lists.frrouting.org |
d1890d04 | 207 | |
b6820993 QY |
208 | Submitting multi-commit patches as a GitHub pull request is **strongly |
209 | encouraged** and increases the probability of your patch getting reviewed and | |
210 | merged in a timely manner. | |
d1890d04 | 211 | |
b6820993 | 212 | .. _license-for-contributions: |
d1890d04 | 213 | |
b6820993 QY |
214 | License for Contributions |
215 | ------------------------- | |
216 | FRR is under a “GPLv2 or later” license. Any code submitted must be released | |
217 | under the same license (preferred) or any license which allows redistribution | |
218 | under this GPLv2 license (eg MIT License). | |
e2abcff8 PG |
219 | It is forbidden to push any code that prevents from using GPLv3 license. This |
220 | becomes a community rule, as FRR produces binaries that links with Apache 2.0 | |
221 | libraries. Apache 2.0 and GPLv2 license are incompatible, if put together. | |
222 | Please see `<http://www.apache.org/licenses/GPL-compatibility.html>`_ for | |
223 | more information. This rule guarantees the user to distribute FRR binary code | |
224 | without any licensing issues. | |
b22ba015 | 225 | |
b6820993 QY |
226 | Pre-submission Checklist |
227 | ------------------------ | |
228 | - Format code (see `Code Formatting <#code-formatting>`__) | |
229 | - Verify and acknowledge license (see :ref:`license-for-contributions`) | |
230 | - Ensure you have properly signed off (see :ref:`signing-off`) | |
231 | - Test building with various configurations: | |
d1890d04 | 232 | |
b6820993 | 233 | - ``buildtest.sh`` |
d1890d04 | 234 | |
b6820993 | 235 | - Verify building source distribution: |
d1890d04 | 236 | |
b6820993 | 237 | - ``make dist`` (and try rebuilding from the resulting tar file) |
d1890d04 | 238 | |
b6820993 | 239 | - Run unit tests: |
d1890d04 | 240 | |
b6820993 | 241 | - ``make test`` |
d1890d04 | 242 | |
b6820993 QY |
243 | - In the case of a major new feature or other significant change, document |
244 | plans for continued maintenance of the feature | |
d1890d04 | 245 | |
b6820993 | 246 | .. _signing-off: |
d1890d04 | 247 | |
b6820993 QY |
248 | Signing Off |
249 | ----------- | |
250 | Code submitted to FRR must be signed off. We have the same requirements for | |
251 | using the signed-off-by process as the Linux kernel. In short, you must include | |
252 | a ``Signed-off-by`` tag in every patch. | |
d1890d04 | 253 | |
b6820993 QY |
254 | ``Signed-off-by`` is a developer's certification that they have the right to |
255 | submit the patch for inclusion into the project. It is an agreement to the | |
256 | :ref:`Developer's Certificate of Origin <developers-certificate-of-origin>`. | |
257 | Code without a proper ``Signed-off-by`` line cannot and will not be merged. | |
d1890d04 | 258 | |
b6820993 QY |
259 | If you are unfamiliar with this process, you should read the |
260 | `official policy at kernel.org <https://www.kernel.org/doc/html/latest/process/submitting-patches.html>`_. | |
261 | You might also find | |
262 | `this article <http://www.linuxfoundation.org/content/how-participate-linux-community-0>`_ | |
263 | about participating in the Linux community on the Linux Foundation website to | |
264 | be a helpful resource. | |
d1890d04 | 265 | |
b6820993 | 266 | .. _developers-certificate-of-origin: |
d1890d04 | 267 | |
b6820993 QY |
268 | In short, when you sign off on a commit, you assert your agreement to all of |
269 | the following:: | |
d1890d04 | 270 | |
b6820993 | 271 | Developer's Certificate of Origin 1.1 |
d1890d04 | 272 | |
b6820993 | 273 | By making a contribution to this project, I certify that: |
d1890d04 | 274 | |
b6820993 QY |
275 | (a) The contribution was created in whole or in part by me and I |
276 | have the right to submit it under the open source license | |
277 | indicated in the file; or | |
d1890d04 | 278 | |
b6820993 QY |
279 | (b) The contribution is based upon previous work that, to the best |
280 | of my knowledge, is covered under an appropriate open source | |
281 | license and I have the right under that license to submit that | |
282 | work with modifications, whether created in whole or in part by | |
283 | me, under the same open source license (unless I am permitted to | |
284 | submit under a different license), as indicated in the file; or | |
d1890d04 | 285 | |
b6820993 QY |
286 | (c) The contribution was provided directly to me by some other |
287 | person who certified (a), (b) or (c) and I have not modified it. | |
d1890d04 | 288 | |
b6820993 QY |
289 | (d) I understand and agree that this project and the contribution |
290 | are public and that a record of the contribution (including all | |
291 | personal information I submit with it, including my sign-off) is | |
292 | maintained indefinitely and may be redistributed consistent with | |
293 | this project or the open source license(s) involved. | |
d1890d04 | 294 | |
b6820993 | 295 | After Submitting Your Changes |
d1890d04 QY |
296 | ----------------------------- |
297 | ||
b6820993 | 298 | - Watch for Continuous Integration (CI) test results |
d1890d04 QY |
299 | |
300 | - You should automatically receive an email with the test results | |
301 | within less than 2 hrs of the submission. If you don’t get the | |
b6820993 | 302 | email, then check status on the GitHub pull request. |
d1890d04 | 303 | - Please notify the development mailing list if you think something |
b22ba015 | 304 | doesn't work. |
d1890d04 QY |
305 | |
306 | - If the tests failed: | |
307 | ||
308 | - In general, expect the community to ignore the submission until | |
309 | the tests pass. | |
310 | - It is up to you to fix and resubmit. | |
311 | ||
312 | - This includes fixing existing unit (“make test”) tests if your | |
313 | changes broke or changed them. | |
314 | - It also includes fixing distribution packages for the failing | |
315 | platforms (ie if new libraries are required). | |
316 | - Feel free to ask for help on the development list. | |
317 | ||
318 | - Go back to the submission process and repeat until the tests pass. | |
319 | ||
320 | - If the tests pass: | |
321 | ||
322 | - Wait for reviewers. Someone will review your code or be assigned | |
323 | to review your code. | |
493e3eed LB |
324 | - Respond to any comments or concerns the reviewer has. Use e-mail or |
325 | add a comment via github to respond or to let the reviewer know how | |
326 | their comment or concern is addressed. | |
327 | - An author must never delete or manually dismiss someone else's comments | |
328 | or review. (A review may be overridden by agreement in the weekly | |
329 | technical meeting.) | |
330 | - Automatically generated comments, e.g., those generated by CI systems, | |
331 | may be deleted by authors and others when such comments are not the most | |
22265b35 | 332 | recent results from that automated comment source. |
d1890d04 QY |
333 | - After all comments and concerns are addressed, expect your patch |
334 | to be merged. | |
335 | ||
336 | - Watch out for questions on the mailing list. At this time there will | |
337 | be a manual code review and further (longer) tests by various | |
338 | community members. | |
339 | - Your submission is done once it is merged to the master branch. | |
340 | ||
9de103f0 QY |
341 | Programming Languages, Tools and Libraries |
342 | ========================================== | |
343 | ||
344 | The core of FRR is written in C (gcc or clang supported) and makes | |
345 | use of GNU compiler extensions. A few non-essential scripts are | |
346 | implemented in Perl and Python. FRR requires the following tools | |
347 | to build distribution packages: automake, autoconf, texinfo, libtool and | |
348 | gawk and various libraries (i.e. libpam and libjson-c). | |
349 | ||
350 | If your contribution requires a new library or other tool, then please | |
351 | highlight this in your description of the change. Also make sure it’s | |
352 | supported by all FRR platform OSes or provide a way to build | |
353 | without the library (potentially without the new feature) on the other | |
354 | platforms. | |
355 | ||
356 | Documentation should be written in reStructuredText. Sphinx extensions may be | |
357 | utilized but pure ReST is preferred where possible. See | |
358 | :ref:`documentation`. | |
359 | ||
590a7368 QY |
360 | Code Reviews |
361 | ============ | |
362 | ||
363 | Code quality is paramount for any large program. Consequently we require | |
364 | reviews of all submitted patches by at least one person other than the | |
365 | submitter before the patch is merged. | |
366 | ||
367 | Because of the nature of the software, FRR's maintainer list (i.e. those with | |
368 | commit permissions) tends to contain employees / members of various | |
369 | organizations. In order to prevent conflicts of interest, we use an honor | |
370 | system in which submissions from an individual representing one company should | |
371 | be merged by someone unaffiliated with that company. | |
372 | ||
373 | Guidelines for code review | |
374 | """""""""""""""""""""""""" | |
375 | ||
376 | - As a rule of thumb, the depth of the review should be proportional to the | |
377 | scope and / or impact of the patch. | |
378 | ||
379 | - Anyone may review a patch. | |
380 | ||
381 | - When using GitHub reviews, marking "Approve" on a code review indicates | |
382 | willingness to merge the PR. | |
383 | ||
384 | - For individuals with merge rights, marking "Changes requested" is equivalent | |
385 | to a NAK. | |
386 | ||
387 | - For a PR you marked with "Changes requested", please respond to updates in a | |
388 | timely manner to avoid impeding the flow of development. | |
389 | ||
7e678379 LB |
390 | - Rejected or obsolete PRs are generally closed by the submitter based |
391 | on requests and/or agreement captured in a PR comment. The comment | |
392 | may originate with a reviewer or document agreement reached on Slack, | |
393 | the Development mailing list, or the weekly technical meeting. | |
394 | ||
590a7368 | 395 | |
b22ba015 | 396 | Coding Practices & Style |
9de103f0 | 397 | ======================== |
d1890d04 QY |
398 | |
399 | Commit messages | |
9de103f0 | 400 | --------------- |
d1890d04 QY |
401 | |
402 | Commit messages should be formatted in the same way as Linux kernel | |
b6820993 | 403 | commit messages. The format is roughly:: |
d1890d04 QY |
404 | |
405 | dir: short summary | |
406 | ||
407 | extended summary | |
408 | ||
b6820993 QY |
409 | ``dir`` should be the top level source directory under which the change was |
410 | made. For example, a change in :file:`bgpd/rfapi` would be formatted as:: | |
d1890d04 | 411 | |
9de103f0 | 412 | bgpd: short summary |
d1890d04 | 413 | |
b6820993 QY |
414 | ... |
415 | ||
416 | The first line should be no longer than 50 characters. Subsequent lines should | |
417 | be wrapped to 72 characters. | |
d1890d04 | 418 | |
b6820993 QY |
419 | You must also sign off on your commit. |
420 | ||
421 | .. seealso:: :ref:`signing-off` | |
422 | ||
423 | Source File Header | |
9de103f0 | 424 | ------------------ |
d1890d04 | 425 | |
b6820993 QY |
426 | New files must have a copyright header (see :ref:`license-for-contributions` |
427 | above) added to the file. The header should be: | |
d1890d04 | 428 | |
b6820993 | 429 | .. code-block:: c |
d1890d04 QY |
430 | |
431 | /* | |
432 | * Title/Function of file | |
433 | * Copyright (C) YEAR Author’s Name | |
434 | * | |
435 | * This program is free software; you can redistribute it and/or modify it | |
436 | * under the terms of the GNU General Public License as published by the Free | |
437 | * Software Foundation; either version 2 of the License, or (at your option) | |
438 | * any later version. | |
439 | * | |
440 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
441 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
442 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
443 | * more details. | |
444 | * | |
445 | * You should have received a copy of the GNU General Public License along | |
446 | * with this program; see the file COPYING; if not, write to the Free Software | |
447 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
448 | */ | |
449 | ||
450 | #include <zebra.h> | |
451 | ||
b6820993 QY |
452 | Please copy-paste this header verbatim. In particular: |
453 | ||
454 | - Do not replace "This program" with "FRR" | |
455 | - Do not change the address of the FSF | |
456 | ||
457 | Adding Copyright Claims to Existing Files | |
9de103f0 | 458 | ----------------------------------------- |
d1890d04 | 459 | |
b6820993 QY |
460 | When adding copyright claims for modifications to an existing file, please |
461 | add a ``Portions:`` section as shown below. If this section already exists, add | |
462 | your new claim at the end of the list. | |
d1890d04 | 463 | |
b6820993 | 464 | .. code-block:: c |
d1890d04 | 465 | |
b6820993 QY |
466 | /* |
467 | * Title/Function of file | |
468 | * Copyright (C) YEAR Author’s Name | |
469 | * Portions: | |
470 | * Copyright (C) 2010 Entity A .... | |
471 | * Copyright (C) 2016 Your name [optional brief change description] | |
472 | * ... | |
473 | */ | |
d1890d04 | 474 | |
c964e511 | 475 | Code Formatting |
9de103f0 | 476 | --------------- |
d1890d04 | 477 | |
b6820993 QY |
478 | FRR uses Linux kernel style except where noted below. Code which does not |
479 | comply with these style guidelines will not be accepted. | |
d1890d04 | 480 | |
281ba953 QY |
481 | The project provides multiple tools to allow you to correctly style your code |
482 | as painlessly as possible, primarily built around ``clang-format``. | |
483 | ||
484 | clang-format | |
485 | In the project root there is a :file:`.clang-format` configuration file | |
486 | which can be used with the ``clang-format`` source formatter tool from the | |
487 | LLVM project. Most of the time, this is the easiest and smartest tool to | |
488 | use. It can be run in a variety of ways. If you point it at a C source file | |
489 | or directory of source files, it will format all of them. In the LLVM source | |
490 | tree there are scripts that allow you to integrate it with ``git``, ``vim`` | |
491 | and ``emacs``, and there are third-party plugins for other editors. The | |
492 | ``git`` integration is particularly useful; suppose you have some changes in | |
493 | your git index. Then, with the integration installed, you can do the | |
494 | following: | |
495 | ||
496 | :: | |
497 | ||
498 | git clang-format | |
499 | ||
500 | This will format *only* the changes present in your index. If you have just | |
501 | made a few commits and would like to correctly style only the changes made | |
502 | in those commits, you can use the following syntax: | |
503 | ||
504 | :: | |
505 | ||
506 | git clang-format HEAD~X | |
507 | ||
508 | Where X is one more than the number of commits back from the tip of your | |
509 | branch you would like ``clang-format`` to look at (similar to specifying the | |
510 | target for a rebase). | |
511 | ||
512 | The ``vim`` plugin is particularly useful. It allows you to select lines in | |
513 | visual line mode and press a key binding to invoke ``clang-format`` on only | |
514 | those lines. | |
515 | ||
516 | When using ``clang-format``, it is recommended to use the latest version. | |
517 | Each consecutive version generally has better handling of various edge | |
518 | cases. You may notice on occasion that two consecutive runs of | |
519 | ``clang-format`` over the same code may result in changes being made on the | |
520 | second run. This is an unfortunate artifact of the tool. Please check with | |
521 | the kernel style guide if in doubt. | |
522 | ||
523 | One stylistic problem with the FRR codebase is the use of ``DEFUN`` macros | |
524 | for defining CLI commands. ``clang-format`` will happily format these macro | |
525 | invocations, but the result is often unsightly and difficult to read. | |
526 | Consequently, FRR takes a more relaxed position with how these are | |
527 | formatted. In general you should lean towards using the style exemplified in | |
528 | the section on :ref:`command-line-interface`. Because ``clang-format`` | |
529 | mangles this style, there is a Python script named ``tools/indent.py`` that | |
530 | wraps ``clang-format`` and handles ``DEFUN`` macros as well as some other | |
531 | edge cases specific to FRR. If you are submitting a new file, it is | |
532 | recommended to run that script over the new file, preferably after ensuring | |
533 | that the latest stable release of ``clang-format`` is in your ``PATH``. | |
534 | ||
535 | Documentation on ``clang-format`` and its various integrations is maintained | |
536 | on the LLVM website. | |
537 | ||
538 | https://clang.llvm.org/docs/ClangFormat.html | |
539 | ||
540 | checkpatch.sh | |
541 | In the Linux kernel source tree there is a Perl script used to check | |
542 | incoming patches for style errors. FRR uses an adapted version of this | |
543 | script for the same purpose. It can be found at | |
2780ae0c | 544 | :file:`tools/checkpatch.sh`. This script takes a git-formatted diff or |
281ba953 QY |
545 | patch file, applies it to a clean FRR tree, and inspects the result to catch |
546 | potential style errors. Running this script on your patches before | |
547 | submission is highly recommended. The CI system runs this script as well and | |
548 | will comment on the PR with the results if style errors are found. | |
549 | ||
b6820993 | 550 | It is run like this:: |
281ba953 | 551 | |
b6820993 | 552 | ./checkpatch.sh <patch> <tree> |
281ba953 QY |
553 | |
554 | Reports are generated on ``stderr`` and the exit code indicates whether | |
555 | issues were found (2, 1) or not (0). | |
556 | ||
557 | Where ``<patch>`` is the path to the diff or patch file and ``<tree>`` is | |
558 | the path to your FRR source tree. The tree should be on the branch that you | |
559 | intend to submit the patch against. The script will make a best-effort | |
560 | attempt to save the state of your working tree and index before applying the | |
561 | patch, and to restore it when it is done, but it is still recommended that | |
562 | you have a clean working tree as the script does perform a hard reset on | |
563 | your tree during its run. | |
564 | ||
565 | The script reports two classes of issues, namely WARNINGs and ERRORs. Please | |
566 | pay attention to both of them. The script will generally report WARNINGs | |
567 | where it cannot be 100% sure that a particular issue is real. In most cases | |
568 | WARNINGs indicate an issue that needs to be fixed. Sometimes the script will | |
569 | report false positives; these will be handled in code review on a | |
570 | case-by-case basis. Since the script only looks at changed lines, | |
571 | occasionally changing one part of a line can cause the script to report a | |
572 | style issue already present on that line that is unrelated to the change. | |
573 | When convenient it is preferred that these be cleaned up inline, but this is | |
574 | not required. | |
575 | ||
115e70a1 PZ |
576 | In general, a developer should heed the information reported by checkpatch. |
577 | However, some flexibility is needed for cases where human judgement yields | |
578 | better clarity than the script. Accordingly, it may be appropriate to | |
579 | ignore some checkpatch.sh warnings per discussion among the submitter(s) | |
580 | and reviewer(s) of a change. Misreporting of errors by the script is | |
d3c2e316 QY |
581 | possible. When this occurs, the exception should be handled either by |
582 | patching checkpatch to correct the false error report, or by documenting the | |
583 | exception in this document under :ref:`style-exceptions`. If the incorrect | |
584 | report is likely to appear again, a checkpatch update is preferred. | |
115e70a1 | 585 | |
281ba953 QY |
586 | If the script finds one or more WARNINGs it will exit with 1. If it finds |
587 | one or more ERRORs it will exit with 2. | |
588 | ||
589 | ||
590 | Please remember that while FRR provides these tools for your convenience, | |
591 | responsibility for properly formatting your code ultimately lies on the | |
592 | shoulders of the submitter. As such, it is recommended to double-check the | |
593 | results of these tools to avoid delays in merging your submission. | |
d1890d04 | 594 | |
115e70a1 PZ |
595 | In some cases, these tools modify or flag the format in ways that go beyond or |
596 | even conflict [#tool_style_conflicts]_ with the canonical documented Linux | |
597 | kernel style. In these cases, the Linux kernel style takes priority; | |
598 | non-canonical issues flagged by the tools are not compulsory but rather are | |
599 | opportunities for discussion among the submitter(s) and reviewer(s) of a change. | |
600 | ||
d1890d04 QY |
601 | **Whitespace changes in untouched parts of the code are not acceptable |
602 | in patches that change actual code.** To change/fix formatting issues, | |
603 | please create a separate patch that only does formatting changes and | |
604 | nothing else. | |
605 | ||
d1890d04 QY |
606 | Kernel and BSD styles are documented externally: |
607 | ||
608 | - https://www.kernel.org/doc/html/latest/process/coding-style.html | |
609 | - http://man.openbsd.org/style | |
610 | ||
611 | For GNU coding style, use ``indent`` with the following invocation: | |
612 | ||
613 | :: | |
614 | ||
615 | indent -nut -nfc1 file_for_submission.c | |
616 | ||
28ac5a03 QY |
617 | |
618 | Historically, FRR used fixed-width integral types that do not exist in any | |
619 | standard but were defined by most platforms at some point. Officially these | |
620 | types are not guaranteed to exist. Therefore, please use the fixed-width | |
621 | integral types introduced in the C99 standard when contributing new code to | |
622 | FRR. If you need to convert a large amount of code to use the correct types, | |
623 | there is a shell script in :file:`tools/convert-fixedwidth.sh` that will do the | |
624 | necessary replacements. | |
625 | ||
626 | +-----------+--------------------------+ | |
627 | | Incorrect | Correct | | |
628 | +===========+==========================+ | |
629 | | u_int8_t | uint8_t | | |
630 | +-----------+--------------------------+ | |
631 | | u_int16_t | uint16_t | | |
632 | +-----------+--------------------------+ | |
633 | | u_int32_t | uint32_t | | |
634 | +-----------+--------------------------+ | |
635 | | u_int64_t | uint64_t | | |
636 | +-----------+--------------------------+ | |
637 | | u_char | uint8_t or unsigned char | | |
638 | +-----------+--------------------------+ | |
639 | | u_short | unsigned short | | |
640 | +-----------+--------------------------+ | |
641 | | u_int | unsigned int | | |
642 | +-----------+--------------------------+ | |
643 | | u_long | unsigned long | | |
644 | +-----------+--------------------------+ | |
645 | ||
d3c2e316 QY |
646 | .. _style-exceptions: |
647 | ||
d1890d04 QY |
648 | Exceptions |
649 | ^^^^^^^^^^ | |
650 | ||
651 | FRR project code comes from a variety of sources, so there are some | |
652 | stylistic exceptions in place. They are organized here by branch. | |
653 | ||
9de103f0 QY |
654 | For ``master`` |
655 | """""""""""""" | |
d1890d04 QY |
656 | |
657 | BSD coding style applies to: | |
658 | ||
659 | - ``ldpd/`` | |
660 | ||
661 | ``babeld`` uses, approximately, the following style: | |
662 | ||
663 | - K&R style braces | |
664 | - Indents are 4 spaces | |
665 | - Function return types are on their own line | |
666 | ||
9de103f0 QY |
667 | For ``stable/3.0`` and ``stable/2.0`` |
668 | """"""""""""""""""""""""""""""""""""" | |
d1890d04 QY |
669 | |
670 | GNU coding style apply to the following parts: | |
671 | ||
672 | - ``lib/`` | |
673 | - ``zebra/`` | |
674 | - ``bgpd/`` | |
675 | - ``ospfd/`` | |
676 | - ``ospf6d/`` | |
677 | - ``isisd/`` | |
678 | - ``ripd/`` | |
679 | - ``ripngd/`` | |
680 | - ``vtysh/`` | |
681 | ||
682 | BSD coding style applies to: | |
683 | ||
684 | - ``ldpd/`` | |
685 | ||
d3c2e316 QY |
686 | |
687 | Specific Exceptions | |
688 | ^^^^^^^^^^^^^^^^^^^ | |
689 | ||
690 | Most of the time checkpatch errors should be corrected. Occasionally as a group | |
691 | maintainers will decide to ignore certain stylistic issues. Usually this is | |
692 | because correcting the issue is not possible without large unrelated code | |
693 | changes. When an exception is made, if it is unlikely to show up again and | |
694 | doesn't warrant an update to checkpatch, it is documented here. | |
695 | ||
696 | +------------------------------------------+---------------------------------------------------------------+ | |
697 | | Issue | Ignore Reason | | |
698 | +==========================================+===============================================================+ | |
699 | | DEFPY_HIDDEN, DEFPY_ATTR: complex macros | DEF* macros cannot be wrapped in parentheses without updating | | |
700 | | should be wrapped in parentheses | all usages of the macro, which would be highly disruptive. | | |
701 | +------------------------------------------+---------------------------------------------------------------+ | |
702 | ||
d1890d04 | 703 | Compile-time conditional code |
9de103f0 | 704 | ----------------------------- |
d1890d04 QY |
705 | |
706 | Many users access FRR via binary packages from 3rd party sources; | |
707 | compile-time code puts inclusion/exclusion in the hands of the package | |
708 | maintainer. Please think very carefully before making code conditional | |
709 | at compile time, as it increases regression testing, maintenance | |
710 | burdens, and user confusion. In particular, please avoid gratuitous | |
711 | ``--enable-…`` switches to the configure script - in general, code | |
712 | should be of high quality and in working condition, or it shouldn’t be | |
713 | in FRR at all. | |
714 | ||
715 | When code must be compile-time conditional, try have the compiler make | |
716 | it conditional rather than the C pre-processor so that it will still be | |
717 | checked by the compiler, even if disabled. For example, | |
718 | ||
719 | :: | |
720 | ||
721 | if (SOME_SYMBOL) | |
722 | frobnicate(); | |
723 | ||
724 | is preferred to | |
725 | ||
726 | :: | |
727 | ||
728 | #ifdef SOME_SYMBOL | |
729 | frobnicate (); | |
730 | #endif /* SOME_SYMBOL */ | |
731 | ||
b6820993 QY |
732 | Note that the former approach requires ensuring that ``SOME_SYMBOL`` will be |
733 | defined (watch your ``AC_DEFINE``\ s). | |
d1890d04 QY |
734 | |
735 | Debug-guards in code | |
9de103f0 | 736 | -------------------- |
d1890d04 | 737 | |
b6820993 QY |
738 | Debugging statements are an important methodology to allow developers to fix |
739 | issues found in the code after it has been released. The caveat here is that | |
740 | the developer must remember that people will be using the code at scale and in | |
741 | ways that can be unexpected for the original implementor. As such debugs | |
742 | **MUST** be guarded in such a way that they can be turned off. FRR has the | |
743 | ability to turn on/off debugs from the CLI and it is expected that the | |
744 | developer will use this convention to allow control of their debugs. | |
d1890d04 | 745 | |
9e001286 QY |
746 | Static Analysis and Sanitizers |
747 | ------------------------------ | |
748 | Clang/LLVM comes with a variety of tools that can be used to help find bugs in FRR. | |
749 | ||
750 | clang-analyze | |
751 | This is a static analyzer that scans the source code looking for patterns | |
752 | that are likely to be bugs. The tool is run automatically on pull requests | |
753 | as part of CI and new static analysis warnings will be placed in the CI | |
754 | results. FRR aims for absolutely zero static analysis errors. While the | |
755 | project is not quite there, code that introduces new static analysis errors | |
756 | is very unlikely to be merged. | |
757 | ||
758 | AddressSanitizer | |
759 | This is an excellent tool that provides runtime instrumentation for | |
760 | detecting memory errors. As part of CI FRR is built with this | |
761 | instrumentation and run through a series of tests to look for any results. | |
762 | Testing your own code with this tool before submission is encouraged. You | |
763 | can enable it by passing:: | |
d5403d4f | 764 | |
9e001286 QY |
765 | --enable-address-sanitizer |
766 | ||
767 | to ``configure``. | |
768 | ||
769 | ThreadSanitizer | |
770 | Similar to AddressSanitizer, this tool provides runtime instrumentation for | |
771 | detecting data races. If you are working on or around multithreaded code, | |
772 | extensive testing with this instrumtation enabled is *highly* recommended. | |
773 | You can enable it by passing:: | |
d5403d4f | 774 | |
9e001286 QY |
775 | --enable-thread-sanitizer |
776 | ||
777 | to ``configure``. | |
778 | ||
779 | MemorySanitizer | |
780 | Similar to AddressSanitizer, this tool provides runtime instrumentation for | |
781 | detecting use of uninitialized heap memory. Testing your own code with this | |
782 | tool before submission is encouraged. You can enable it by passing:: | |
d5403d4f | 783 | |
9e001286 QY |
784 | --enable-memory-sanitizer |
785 | ||
786 | to ``configure``. | |
787 | ||
788 | All of the above tools are available in the Clang/LLVM toolchain since 3.4. | |
789 | AddressSanitizer and ThreadSanitizer are available in recent versions of GCC, | |
790 | but are no longer actively maintained. MemorySanitizer is not available in GCC. | |
791 | ||
792 | Additionally, the FRR codebase is regularly scanned with Coverity. | |
793 | Unfortunately Coverity does not have the ability to handle scanning pull | |
794 | requests, but after code is merged it will send an email notifying project | |
795 | members with Coverity access of newly introduced defects. | |
796 | ||
d1890d04 | 797 | CLI changes |
9de103f0 | 798 | ----------- |
d1890d04 | 799 | |
b6820993 QY |
800 | CLI's are a complicated ugly beast. Additions or changes to the CLI should use |
801 | a DEFUN to encapsulate one setting as much as is possible. Additionally as new | |
802 | DEFUN's are added to the system, documentation should be provided for the new | |
803 | commands. | |
d1890d04 QY |
804 | |
805 | Backwards Compatibility | |
9de103f0 | 806 | ----------------------- |
d1890d04 | 807 | |
b6820993 QY |
808 | As a general principle, changes to CLI and code in the lib/ directory should be |
809 | made in a backwards compatible fashion. This means that changes that are purely | |
810 | stylistic in nature should be avoided, e.g., renaming an existing macro or | |
811 | library function name without any functional change. When adding new parameters | |
812 | to common functions, it is also good to consider if this too should be done in | |
813 | a backward compatible fashion, e.g., by preserving the old form in addition to | |
d1890d04 QY |
814 | adding the new form. |
815 | ||
b6820993 QY |
816 | This is not to say that minor or even major functional changes to CLI and |
817 | common code should be avoided, but rather that the benefit gained from a change | |
818 | should be weighed against the added cost/complexity to existing code. Also, | |
819 | that when making such changes, it is good to preserve compatibility when | |
820 | possible to do so without introducing maintenance overhead/cost. It is also | |
821 | important to keep in mind, existing code includes code that may reside in | |
822 | private repositories (and is yet to be submitted) or code that has yet to be | |
823 | migrated from Quagga to FRR. | |
110bb121 | 824 | |
b6820993 QY |
825 | That said, compatibility measures can (and should) be removed when either: |
826 | ||
827 | - they become a significant burden, e.g. when data structures change and the | |
828 | compatibility measure would need a complex adaptation layer or becomes | |
829 | flat-out impossible | |
830 | - some measure of time (dependent on the specific case) has passed, so that | |
831 | the compatibility grace period is considered expired. | |
832 | ||
e12ea4bb QY |
833 | For CLI commands, the deprecation period is 1 year. |
834 | ||
b6820993 QY |
835 | In all cases, compatibility pieces should be marked with compiler/preprocessor |
836 | annotations to print warnings at compile time, pointing to the appropriate | |
837 | update path. A ``-Werror`` build should fail if compatibility bits are used. To | |
838 | avoid compilation issues in released code, such compiler/preprocessor | |
839 | annotations must be ignored non-development branches. For example: | |
840 | ||
841 | .. code-block:: c | |
842 | ||
e60dd6ca | 843 | #if CONFDATE > 20180403 |
b6820993 QY |
844 | CPP_NOTICE("Use of <XYZ> is deprecated, please use <ABC>") |
845 | #endif | |
d1890d04 | 846 | |
cab3f811 LB |
847 | Preferably, the shell script :file:`tools/fixup-deprecated.py` will be |
848 | updated along with making non-backwards compatible code changes, or an | |
849 | alternate script should be introduced, to update the code to match the | |
850 | change. When the script is updated, there is no need to preserve the | |
851 | deprecated code. Note that this does not apply to user interface | |
852 | changes, just internal code, macros and libraries. | |
853 | ||
d1890d04 | 854 | Miscellaneous |
9de103f0 | 855 | ------------- |
d1890d04 | 856 | |
b6820993 QY |
857 | When in doubt, follow the guidelines in the Linux kernel style guide, or ask on |
858 | the development mailing list / public Slack instance. | |
9de103f0 QY |
859 | |
860 | ||
861 | .. _documentation: | |
862 | ||
863 | Documentation | |
864 | ============= | |
865 | ||
866 | FRR uses Sphinx+RST as its documentation system. The document you are currently | |
867 | reading was generated by Sphinx from RST source in | |
868 | :file:`doc/developer/workflow.rst`. The documentation is structured as follows: | |
869 | ||
d5403d4f QY |
870 | +-----------------------+-------------------------------------------+ |
871 | | Directory | Contents | | |
872 | +=======================+===========================================+ | |
873 | | :file:`doc/user` | User documentation; configuration guides; | | |
874 | | | protocol overviews | | |
875 | +-----------------------+-------------------------------------------+ | |
876 | | :file:`doc/developer` | Developer's documentation; API specs; | | |
877 | | | datastructures; architecture overviews; | | |
878 | | | project management procedure | | |
879 | +-----------------------+-------------------------------------------+ | |
880 | | :file:`doc/manpages` | Source for manpages | | |
881 | +-----------------------+-------------------------------------------+ | |
882 | | :file:`doc/figures` | Images and diagrams | | |
883 | +-----------------------+-------------------------------------------+ | |
884 | | :file:`doc/extra` | Miscellaneous Sphinx extensions, scripts, | | |
885 | | | customizations, etc. | | |
886 | +-----------------------+-------------------------------------------+ | |
887 | ||
888 | Each of these directories, with the exception of :file:`doc/figures` and | |
889 | :file:`doc/extra`, contains a Sphinx-generated Makefile and configuration | |
890 | script :file:`conf.py` used to set various document parameters. The makefile | |
891 | can be used for a variety of targets; invoke `make help` in any of these | |
892 | directories for a listing of available output formats. For convenience, there | |
893 | is a top-level :file:`Makefile.am` that has targets for PDF and HTML | |
894 | documentation for both developer and user documentation, respectively. That | |
895 | makefile is also responsible for building manual pages packed with distribution | |
896 | builds. | |
9de103f0 QY |
897 | |
898 | Indent and styling should follow existing conventions: | |
899 | ||
900 | - 3 spaces for indents under directives | |
901 | - Cross references may contain only lowercase alphanumeric characters and | |
902 | hyphens ('-') | |
903 | - Lines wrapped to 80 characters where possible | |
904 | ||
905 | Characters for header levels should follow Python documentation guide: | |
906 | ||
907 | - ``#`` with overline, for parts | |
908 | - ``*`` with overline, for chapters | |
909 | - ``=``, for sections | |
910 | - ``-``, for subsections | |
911 | - ``^``, for subsubsections | |
912 | - ``"``, for paragraphs | |
913 | ||
914 | After you have made your changes, please make sure that you can invoke | |
915 | ``make latexpdf`` and ``make html`` with no warnings. | |
916 | ||
917 | The documentation is currently incomplete and needs love. If you find a broken | |
918 | cross-reference, figure, dead hyperlink, style issue or any other nastiness we | |
919 | gladly accept documentation patches. | |
920 | ||
c91e9b8f QY |
921 | To build the docs, please ensure you have installed a recent version of |
922 | `Sphinx <http://www.sphinx-doc.org/en/stable/install.html>`_. If you want to | |
923 | build LaTeX or PDF docs, you will also need a full LaTeX distribution | |
924 | installed. | |
925 | ||
9de103f0 QY |
926 | Code |
927 | ---- | |
928 | ||
929 | FRR is a large and complex software project developed by many different people | |
930 | over a long period of time. Without adequate documentation, it can be | |
931 | exceedingly difficult to understand code segments, APIs and other interfaces. | |
932 | In the interest of keeping the project healthy and maintainable, you should | |
933 | make every effort to document your code so that other people can understand | |
934 | what it does without needing to closely read the code itself. | |
935 | ||
936 | Some specific guidelines that contributors should follow are: | |
937 | ||
938 | - Functions exposed in header files should have descriptive comments above | |
939 | their signatures in the header file. At a minimum, a function comment should | |
940 | contain information about the return value, parameters, and a general summary | |
941 | of the function's purpose. Documentation on parameter values can be omitted | |
942 | if it is (very) obvious what they are used for. | |
943 | ||
944 | Function comments must follow the style for multiline comments laid out in | |
945 | the kernel style guide. | |
946 | ||
947 | Example: | |
948 | ||
949 | .. code-block:: c | |
950 | ||
951 | /* | |
952 | * Determines whether or not a string is cool. | |
953 | * | |
b6820993 QY |
954 | * text |
955 | * the string to check for coolness | |
956 | * | |
957 | * is_clccfc | |
958 | * whether capslock is cruise control for cool | |
959 | * | |
960 | * Returns: | |
961 | * 7 if the text is cool, 0 otherwise | |
9de103f0 QY |
962 | */ |
963 | int check_coolness(const char *text, bool is_clccfc); | |
964 | ||
b6820993 QY |
965 | Function comments should make it clear what parameters and return values are |
966 | used for. | |
9de103f0 QY |
967 | |
968 | - Static functions should have descriptive comments in the same form as above | |
969 | if what they do is not immediately obvious. Use good engineering judgement | |
970 | when deciding whether a comment is necessary. If you are unsure, document | |
971 | your code. | |
972 | - Global variables, static or not, should have a comment describing their use. | |
973 | - **For new code in lib/, these guidelines are hard requirements.** | |
974 | ||
975 | If you make significant changes to portions of the codebase covered in the | |
976 | Developer's Manual, add a major subsystem or feature, or gain arcane mastery of | |
977 | some undocumented or poorly documented part of the codebase, please document | |
978 | your work so others can benefit. If you add a major feature or introduce a new | |
979 | API, please document the architecture and API to the best of your abilities in | |
980 | the Developer's Manual, using good judgement when choosing where to place it. | |
981 | ||
982 | Finally, if you come across some code that is undocumented and feel like | |
983 | going above and beyond, document it! We absolutely appreciate and accept | |
984 | patches that document previously undocumented code. | |
985 | ||
986 | User | |
987 | ---- | |
988 | ||
989 | If you are contributing code that adds significant user-visible functionality | |
990 | please document how to use it in :file:`doc/user`. Use good judgement when | |
991 | choosing where to place documentation. For example, instructions on how to use | |
992 | your implementation of a new BGP draft should go in the BGP chapter instead of | |
993 | being its own chapter. If you are adding a new protocol daemon, please create a | |
994 | new chapter. | |
995 | ||
d5403d4f QY |
996 | FRR Specific Markup |
997 | ------------------- | |
998 | ||
999 | FRR has some customizations applied to the Sphinx markup that go a long way | |
1000 | towards making documentation easier to use, write and maintain. | |
1001 | ||
1002 | CLI Commands | |
1003 | ^^^^^^^^^^^^ | |
1004 | ||
9de103f0 QY |
1005 | When documenting CLI please use a combination of the ``.. index::`` and |
1006 | ``.. clicmd::`` directives. For example, the command :clicmd:`show pony` would | |
1007 | be documented as follows: | |
1008 | ||
1009 | .. code-block:: rest | |
1010 | ||
1011 | .. index:: show pony | |
1012 | .. clicmd:: show pony | |
1013 | ||
1014 | Prints an ASCII pony. Example output::: | |
1015 | ||
1016 | >>\. | |
1017 | /_ )`. | |
1018 | / _)`^)`. _.---. _ | |
1019 | (_,' \ `^-)"" `.\ | |
1020 | | | \ | |
1021 | \ / | | |
1022 | / \ /.___.'\ (\ (_ | |
1023 | < ,"|| \ |`. \`-' | |
1024 | \\ () )| )/ | |
1025 | hjw |_>|> /_] // | |
1026 | /_] /_] | |
1027 | ||
1028 | When documented this way, CLI commands can be cross referenced with the | |
1029 | ``:clicmd:`` inline markup like so: | |
1030 | ||
1031 | .. code-block:: rest | |
1032 | ||
1033 | :clicmd:`show pony` | |
1034 | ||
1035 | This is very helpful for users who want to quickly remind themselves what a | |
1036 | particular command does. | |
1037 | ||
d5403d4f QY |
1038 | Configuration Snippets |
1039 | ^^^^^^^^^^^^^^^^^^^^^^ | |
1040 | ||
1041 | When putting blocks of example configuration please use the | |
1042 | ``.. code-block::`` directive and specify ``frr`` as the highlighting language, | |
1043 | as in the following example. This will tell Sphinx to use a custom Pygments | |
1044 | lexer to highlight FRR configuration syntax. | |
1045 | ||
1046 | .. code-block:: rest | |
1047 | ||
1048 | .. code-block:: frr | |
1049 | ||
1050 | ! | |
1051 | ! Example configuration file. | |
1052 | ! | |
1053 | log file /tmp/log.log | |
1054 | service integrated-vtysh-config | |
1055 | ! | |
1056 | ip route 1.2.3.0/24 reject | |
1057 | ipv6 route de:ea:db:ee:ff::/64 reject | |
1058 | ! | |
1059 | ||
1060 | ||
9de103f0 QY |
1061 | .. _GitHub: https://github.com/frrouting/frr |
1062 | .. _GitHub issues: https://github.com/frrouting/frr/issues | |
115e70a1 PZ |
1063 | |
1064 | .. rubric:: Footnotes | |
1065 | ||
1066 | .. [#tool_style_conflicts] For example, lines over 80 characters are allowed | |
1067 | for text strings to make it possible to search the code for them: please | |
1068 | see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ | |
1069 | and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. |