-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add style guide, tidy dev/contrib docs, update docs sites (#1870)
Add styleguide section and guidelines/conventions to RTD site, transcribed from Feb. 2024 developer meeting. Include very minimal sample module, maybe others can extend? Clean up DEVELOPER.md and CONTRIBUTING.md. Describe fprettify and check_format.py usage, update outdated parts of contributing guide, update outdated TOCs, don't detail git commands, contributors can discover these elsewhere. Remove update_fortran_style.py with view to moving related efforts to fprettify eventually. Existing code can be updated manually/opportunistically for now. Minor improvements/cleanup to docs sites including: * rename RTD site "MODFLOW 6 Program Documentation" -> "MODFLOW 6" * rename api ref site "Source Code Documentation" -> "API Reference" * update api ref site brief to "USGS Modular Hydrologic Model" * update section names in TOCs * bump copyright date years * minor explication Merging now to get an initial render up on RTD, @Manangka has platform-specific fixes and more to come in a separate PR.
- Loading branch information
Showing
12 changed files
with
221 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# MODFLOW 6 Source Code Documentation | ||
# Overview | ||
|
||
The documentation here is extracted from the source code by [doxygen](https://www.doxygen.nl/index.html). | ||
|
||
The source code repository is hosted at https://github.com/MODFLOW-USGS/modflow6 where full details can be found. | ||
The source code repository is hosted [on GitHub](https://github.com/MODFLOW-USGS/modflow6). | ||
|
||
MODFLOW 6 usage documentation can be found at https://modflow6.readthedocs.io/en/latest/ | ||
This documentation is intended for MODFLOW 6 contributors and users of the MODFLOW 6 library/API. MODFLOW 6 usage documentation can be found [on ReadTheDocs](https://modflow6.readthedocs.io/en/latest/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Style Guide | ||
|
||
The goal of this guide is to provide a standard for MODFLOW 6 contributors to follow, in pursuit of consistent, readable, well-organized, and unsurprising source code. | ||
|
||
MODFLOW 6 is written in Fortran — largely Fortran 2003, with sparse use of a few 2008 language features. This guide assumes familiarity with the Fortran language. | ||
|
||
## Amendments | ||
|
||
Suggestions to change or extend the style conventions are welcome. Suggestions should be accompanied by a good case for the change. Bear in mind that a goal of this guide is to minimize time spent thinking about questions of style. | ||
|
||
## Conventions | ||
|
||
* Use `CamelCase` for source file names. | ||
* Use `CamelCase` for module and derived type names. | ||
* Use a noun or noun phrase for module and derived type names. | ||
* Use `snake_case` for procedure names. | ||
* Use a verb or verb phrase for procedure names. | ||
* End module names with `...Module`. | ||
* Derived type names may, but need not, end with `...Type`. | ||
* If a source file exists primarily to host a module, name the source file and module identically, except for trailing `...Module`. | ||
* If a module exists primarily to host a type, name the module and type identically, except for trailing `...Module` and `...Type`. | ||
* Include the module/subroutine/function name in `end module`, `end subroutine` and `end function` statements. | ||
* Don't end procedures with a `return` statement; use `return` only to return early. | ||
* Avoid `goto` statements. | ||
* Use `implicit none` in all modules. | ||
* Avoid `implicit none` in procedures except where necessary (e.g. interface bodies). | ||
* Don't use implicit dummy arguments or local variables. | ||
* Make modules `private` by default. Mark `public` types and procedures explicitly. | ||
* Specify precision for logicals, integers and reals with the data types defined in `src/Utilities/kind.f90`. | ||
* Avoid empty comments. | ||
* Avoid comments starting with `--`. | ||
* Include blank lines between: | ||
* module declaration and `use...` statements | ||
* `use...` statements and procedure declarations | ||
* derived type declaration and member variables | ||
* member variables and `contains` statements | ||
* Prefer explicitly specified imports with `use ..., only: ...`, rather than merely `use ...`. | ||
* Prefer importing items used throughout a module with a module-scoped `use` statement, rather than separately in multiple procedures. | ||
* Use [Doxygen format](https://www.doxygen.nl/manual/docblocks.html#fortranblocks) for docstrings. For dummy arguments, use either `@param ...` above the signature or `!< ...` next to the dummy argument. | ||
* Name type-bound procedures' first dummy argument `this`. A suitable docstring is `!< this instance`. | ||
* Avoid deeply nested control structures where possible. | ||
* Prefer verbose names, except where the meaning is obvious from context or precedent. E.g., well-known index variables (`i`, `j`, `m`, `n`). | ||
* Use named constants. Avoid [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)). | ||
|
||
## Sample Module | ||
|
||
Below is a minimal module demonstrating some (but not all) of the conventions. | ||
|
||
```f90 | ||
module SampleModule | ||
use KindModule, only: DP, I4B, LGP | ||
use ConstantsModule, only: DPI | ||
implicit none | ||
private | ||
public :: run_sample | ||
contains | ||
subroutine run_sample(verbose) | ||
logical(LGP), intent(in) :: verbose | ||
integer(I4B) :: answer | ||
real(DP) :: pi | ||
answer = 42 | ||
pi = DPI | ||
if (verbose) then | ||
print *, 'pi: ', pi | ||
print *, 'answer to the ultimate question of life,'& | ||
' the universe, and everything: ', answer | ||
end if | ||
end subroutine run_sample | ||
end module SampleModule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.