Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize on c++ rather than cpp for code tabs #2472

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/docs/contributing/frc-docs/style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ When possible, instead of using code blocks, an RLI should be used. This pulls
:lineno-start: 44

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/RamseteController/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 18-30
:linenos:
:lineno-start: 18
Expand All @@ -136,7 +136,7 @@ To create code tabs in an article, you can use the ``.. tab-set-code::`` directi
:lineno-start: 44


.. code-block:: cpp
.. code-block:: c++
// Start the timer.
m_timer.Start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The second part of state-space notation relates the system's current :term:`stat
The ``LinearSystem`` class contains methods for easily creating state-space systems identified using :term:`system identification`. This example shows a flywheel model with a kV of 0.023 and a kA of 0.001:

.. tab-set::
.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java
Expand All @@ -77,16 +77,16 @@ The ``LinearSystem`` class contains methods for easily creating state-space syst


.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 17
:linenos:
:lineno-start: 17

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 30-46
:linenos:
:lineno-start: 30
Expand All @@ -105,7 +105,7 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe

.. tab-set::

.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java
Expand All @@ -115,16 +115,16 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe
:lineno-start: 34

.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 17-17
:linenos:
:lineno-start: 17

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 17,31-46
:linenos:
:lineno-start: 31
Expand All @@ -145,7 +145,7 @@ Because the feedback controller computes error using the :term:`x-hat` estimated

.. tab-set::

.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java
Expand All @@ -155,16 +155,16 @@ Because the feedback controller computes error using the :term:`x-hat` estimated
:lineno-start: 59

.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 13-13
:linenos:
:lineno-start: 13

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 48-53
:linenos:
:lineno-start: 48
Expand All @@ -182,7 +182,7 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage

.. tab-set::

.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java
Expand All @@ -192,16 +192,16 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage
:lineno-start: 60

.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 11
:linenos:
:lineno-start: 11

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 55-75
:linenos:
:lineno-start: 54
Expand All @@ -213,7 +213,7 @@ LinearSystemLoop combines our system, controller, and observer that we created e

.. tab-set::

.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java
Expand All @@ -223,16 +223,16 @@ LinearSystemLoop combines our system, controller, and observer that we created e
:lineno-start: 73

.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 15-15
:linenos:
:lineno-start: 15

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 71-74
:linenos:
:lineno-start: 71
Expand All @@ -241,7 +241,7 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run

.. tab-set::

.. tab-item:: JAVA
.. tab-item:: Java
:sync: java

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java
Expand All @@ -251,16 +251,16 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run
:lineno-start: 96

.. tab-item:: C++
:sync: cpp
:sync: c++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 5-17
:linenos:
:lineno-start: 5

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 92-114
:linenos:
:lineno-start: 92
Expand All @@ -278,7 +278,7 @@ Mechanisms with a continuous angle can have that angle wrapped by calling the co
error.set(0, 0, MathUtil.angleModulus(error.get(0, 0)));
var u = lqr.getK().times(error);

.. code-block:: cpp
.. code-block:: c++

Eigen::Vector<double, 2> error = lqr.R() - x;
error(0) = frc::AngleModulus(units::radian_t{error(0)}).value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ WPILib's Kalman Filter classes' constructors take a linear system, a vector of p
.. tab-item:: C++

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 5-18
:linenos:
:lineno-start: 5

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 48-53
:linenos:
:lineno-start: 48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The returned adjusted speeds can be converted to usable speeds using the kinemat
double left = wheelSpeeds.leftMetersPerSecond;
double right = wheelSpeeds.rightMetersPerSecond;

.. code-block:: cpp
.. code-block:: c++

ChassisSpeeds adjustedSpeeds = controller.Calculate(currentRobotPose, goal);
DifferentialDriveWheelSpeeds wheelSpeeds = kinematics.ToWheelSpeeds(adjustedSpeeds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Here is an example of generating a trajectory using clamped cubic splines for th
.. tab-item:: C++

.. literalinclude:: examples/trajectory-generation-1/cpp/ExampleTrajectory.cpp
:language: cpp
:language: c++
:lines: 8-22

.. note:: The Java code utilizes the `Units <https://github.wpilib.org/allwpilib/docs/beta/java/edu/wpi/first/math/util/Units.html>`_ utility, for easy unit conversions.
Expand Down Expand Up @@ -90,7 +90,7 @@ Trajectories in Java can be combined into a single trajectory using the ``concat

var concatTraj = trajectoryOne.concatenate(trajectoryTwo);

.. code-block:: cpp
.. code-block:: c++

auto trajectoryOne = frc::TrajectoryGenerator::GenerateTrajectory(
frc::Pose2d(0_m, 0_m, 0_rad),
Expand Down
4 changes: 2 additions & 2 deletions source/docs/software/basic-programming/functions-as-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ This sounds a lot more complicated than it is to use in practice. Let's look at

.. note:: The ``requirements`` parameter is explained in the :ref:`Command-based documentation <docs/software/commandbased/commands:getRequirements>`, and will not be discussed here.

.. code-block:: cpp
.. code-block:: c++

CommandPtr RunOnce(
std::function<void()> action,
Expand All @@ -129,7 +129,7 @@ Lambda Expressions in C++

To pass a function to ``runOnce``, we need to write a short inline function expression using a special syntax that resembles ordinary C++ function declarations, but varies in a few important ways:

.. code-block:: cpp
.. code-block:: c++

// Create an InstantCommand that runs the drive forward at half speed
CommandPtr driveHalfSpeed = cmd::RunOnce([this] { drivetrain.ArcadeDrive(0.5, 0.0); }, {drivetrain});
Expand Down
10 changes: 5 additions & 5 deletions source/docs/software/basic-programming/robot-preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Initializing Preferences
:sync: C++

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Constants.h
:language: cpp
:language: c++
:lines: 30-34

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
:language: cpp
:language: c++
:lines: 12, 18-22

.. tab-item:: Python
Expand Down Expand Up @@ -66,7 +66,7 @@ Reading Preferences
:sync: C++

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
:language: cpp
:language: c++
:lines: 44-52

.. tab-item:: Python
Expand Down Expand Up @@ -96,10 +96,10 @@ Depending on the data that is stored in preferences, you can use it when you rea
:sync: C++

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 15-24
.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
:language: cpp
:language: c++
:lines: 54-60

.. tab-item:: Python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Reading the Bus Voltage


.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 28-31
:linenos:
:lineno-start: 28
Expand All @@ -59,7 +59,7 @@ Reading the Temperature
:lineno-start: 37

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 33-35
:linenos:
:lineno-start: 33
Expand All @@ -78,7 +78,7 @@ Reading the Total Current, Power, and Energy
:lineno-start: 41

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 37-49
:linenos:
:lineno-start: 37
Expand All @@ -99,7 +99,7 @@ The PDP/PDH also allows users to monitor the current drawn by the individual dev
:lineno-start: 26

.. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp
:language: cpp
:language: c++
:lines: 22-26
:linenos:
:lineno-start: 22
Expand Down
Loading