Skip to content

Commit 320c019

Browse files
committed
Format demo code in reference
Some of the library reference pages provide code demonstrating usage. In some places, this code had a very odd formatting where the first indent was three spaces, followed by the standard two space indent for the rest. This made the structure of the code difficult to follow and also results in an unexpected diff when the user runs the formatter on the code in Arduino IDE or Web Editor. It also makes it unfriendly to contributors. All code in the reference is hereby formatted to be compliant with the Arduino IDE 2.x auto formatter (which uses a configuration equivalent that of the formatters in Arduino IDE 1.x and Arduino Web Editor).
1 parent aa96633 commit 320c019

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

docs/api.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -669,29 +669,29 @@ void loop() {
669669
}
670670
671671
void printDirectory(File dir, int numTabs) {
672-
while(true) {
673-
674-
File entry = dir.openNextFile();
675-
if (! entry) {
676-
// No more files
677-
// Serial.println("**nomorefiles**");
678-
break;
679-
}
680-
681-
for (uint8_t i=0; i<numTabs; i++) {
682-
Serial.print('\t');
683-
}
684-
685-
Serial.print(entry.name());
686-
if (entry.isDirectory()) {
687-
Serial.println("/");
688-
printDirectory(entry, numTabs+1);
689-
} else {
690-
// Files have sizes, directories do not
691-
Serial.print("\t\t");
692-
Serial.println(entry.size(), DEC);
693-
}
694-
}
672+
while (true) {
673+
674+
File entry = dir.openNextFile();
675+
if (!entry) {
676+
// No more files
677+
// Serial.println("**nomorefiles**");
678+
break;
679+
}
680+
681+
for (uint8_t i = 0; i < numTabs; i++) {
682+
Serial.print('\t');
683+
}
684+
685+
Serial.print(entry.name());
686+
if (entry.isDirectory()) {
687+
Serial.println("/");
688+
printDirectory(entry, numTabs + 1);
689+
} else {
690+
// Files have sizes, directories do not
691+
Serial.print("\t\t");
692+
Serial.println(entry.size(), DEC);
693+
}
694+
}
695695
}
696696
```
697697

@@ -745,7 +745,7 @@ void setup() {
745745
delay(2000);
746746
747747
Serial.println();
748-
Serial.println("Rewinding, and repeating below:" );
748+
Serial.println("Rewinding, and repeating below:");
749749
Serial.println();
750750
delay(2000);
751751
@@ -761,7 +761,7 @@ void loop() {
761761
void printDirectory(File dir, int numTabs) {
762762
while (true) {
763763
File entry = dir.openNextFile();
764-
if (! entry) {
764+
if (!entry) {
765765
if (numTabs == 0)
766766
Serial.println("** Done **");
767767
return;
@@ -841,29 +841,29 @@ void loop() {
841841
}
842842
843843
void printDirectory(File dir, int numTabs) {
844-
while(true) {
845-
File entry = dir.openNextFile();
846-
if (! entry) {
847-
// No more files
848-
// Return to the first file in the directory
849-
dir.rewindDirectory();
850-
break;
851-
}
852-
853-
for (uint8_t i=0; i<numTabs; i++) {
854-
Serial.print('\t');
855-
}
856-
857-
Serial.print(entry.name());
858-
if (entry.isDirectory()) {
859-
Serial.println("/");
860-
printDirectory(entry, numTabs+1);
861-
} else {
862-
// Files have sizes, directories do not
863-
Serial.print("\t\t");
864-
Serial.println(entry.size(), DEC);
865-
}
866-
}
844+
while (true) {
845+
File entry = dir.openNextFile();
846+
if (!entry) {
847+
// No more files
848+
// Return to the first file in the directory
849+
dir.rewindDirectory();
850+
break;
851+
}
852+
853+
for (uint8_t i = 0; i < numTabs; i++) {
854+
Serial.print('\t');
855+
}
856+
857+
Serial.print(entry.name());
858+
if (entry.isDirectory()) {
859+
Serial.println("/");
860+
printDirectory(entry, numTabs + 1);
861+
} else {
862+
// Files have sizes, directories do not
863+
Serial.print("\t\t");
864+
Serial.println(entry.size(), DEC);
865+
}
866+
}
867867
}
868868
```
869869

0 commit comments

Comments
 (0)