A website devoted to technical training for the First Tech Challenge
How to enable Android Studio to give you information on the functions that you are using.
In order to effectively use the FIRST Tech Challenge software, one needs to really understand some of the small details associated with each function that is provided. The best method to get this information is simply to read the documentation for the software package. The problem there though, particularly for teams who are just starting off, is that the functionality provided by te FIRST software is massive, and trying to sift through the documentation to find specifics on the function that you think you need to use can be difficult. Or, in some circumstances, the links to the documentation are blocked due to security restrictions within the school IT infrastructure.
Alas, all hope is not lost. Good code practices ensure that functions are commented with this same documentation, and therefore Android Studio can parse this and provide you information directly in the IDE without you having to find the website and look it up. This documentation popup can be enabled such that it triggers after a specified amount of time after hovering your cursor over a function. For example, see the popup below on the DcMotor class setPower function:.
Notice all of the information that is provided here! At the top we are told where this function was defined (within DcMotorSimple), and then we have a nice human-readable explanation for what the function does. There is even a little hint in there about what setting the power to zero does. Then there is a list of the available parameters (in this case only one), and what ranges they should take.
Did you know that if you following good code practice, you can actually automatically enable Android Studio to create documentation just like this for functions that you or your team write? If you look at the function below, called "sendNinjas," you will notice a section of comments between lines 1 and 10 right above the function itself. This has a special syntax called Javadoc, that when followed correctly allows Android Studio to parse the code, and provide this information to you in the IDE itself.
1 | /** | |
2 | * Sends Ninjas to help. | |
3 | * <p> | |
4 | * Triggers a command to send Ninjas in your general direction for help. | |
5 | * Uses the smoke signaling technique pioneered by the Greek historian Polybius. | |
6 | * </p> | |
7 | * Note: In high wind days, one should resort to other forms of sending ninjas. | |
8 | * | |
9 | * @param countToSend The number of ninjas to send. | |
10 | * @return Whether or not the ninjas were successfully sent. | |
11 | private boolean sendNinjas(int countToSend) { | |
12 | // Detailed code... | |
13 | } |
As you can see below, now that I have included this Javadoc into my code, when I'm using that function elsewhere in Android Studio, the system will automatically parse the comment block and provide me the information right where I need it.
In order to configure Android Studio to activate auto display of documentation, perform the following steps within Android Studio:
FTC Ninja