Skip to content

Commit e8d2c60

Browse files
authored
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.
1 parent a25df37 commit e8d2c60

File tree

12 files changed

+221
-413
lines changed

12 files changed

+221
-413
lines changed

.build_rtd_docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PROJECT_NUMBER = "version 6.6.0.dev0"
4343
# for a project that appears at the top of each page and should give viewer a
4444
# quick idea about the purpose of the project. Keep the description short.
4545

46-
PROJECT_BRIEF = "MODFLOW 6 Code Documentation"
46+
PROJECT_BRIEF = "USGS Modular Hydrologic Model"
4747

4848
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
4949
# in the documentation. The maximum height of the logo should not exceed 55

.build_rtd_docs/MAINPAGE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# MODFLOW 6 Source Code Documentation
1+
# Overview
22

33
The documentation here is extracted from the source code by [doxygen](https://www.doxygen.nl/index.html).
44

5-
The source code repository is hosted at https://github.com/MODFLOW-USGS/modflow6 where full details can be found.
5+
The source code repository is hosted [on GitHub](https://github.com/MODFLOW-USGS/modflow6).
66

7-
MODFLOW 6 usage documentation can be found at https://modflow6.readthedocs.io/en/latest/
7+
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/).

.build_rtd_docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191

9292
# -- Project information -----------------------------------------------------
9393

94-
project = "MODFLOW 6 Program Documentation"
95-
copyright = "2023, MODFLOW Development Team"
94+
project = "MODFLOW 6"
95+
copyright = "2024, MODFLOW Development Team"
9696
author = "MODFLOW Development Team"
9797

9898
# -- Project version ---------------------------------------------------------

.build_rtd_docs/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Contents:
1111
.. toctree::
1212
:maxdepth: 2
1313

14-
MODFLOW 6 Source Code Documentation <https://modflow-usgs.github.io/modflow6/>
15-
mf6io
14+
API Reference <https://modflow-usgs.github.io/modflow6/>
1615
_mf6run/run-time-comparison.md
1716
_mf6run/deprecations.md
17+
mf6io
18+
styleguide.md
1819

.build_rtd_docs/mf6io.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
MODFLOW 6 Input Guide
2-
---------------------
1+
Input Guide
2+
-----------
33

4-
The latest version of the complete MODFLOW 6 input output guide can be found
4+
The latest version of the complete MODFLOW 6 input/output guide can be found
55
`here <https://github.com/MODFLOW-USGS/modflow6-nightly-build/releases/>`_.
6+
This section enumerates and describes MODFLOW 6 input files.
67

78
Simulation
89
^^^^^^^^^^

.build_rtd_docs/styleguide.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Style Guide
2+
3+
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.
4+
5+
MODFLOW 6 is written in Fortran &mdash; largely Fortran 2003, with sparse use of a few 2008 language features. This guide assumes familiarity with the Fortran language.
6+
7+
## Amendments
8+
9+
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.
10+
11+
## Conventions
12+
13+
* Use `CamelCase` for source file names.
14+
* Use `CamelCase` for module and derived type names.
15+
* Use a noun or noun phrase for module and derived type names.
16+
* Use `snake_case` for procedure names.
17+
* Use a verb or verb phrase for procedure names.
18+
* End module names with `...Module`.
19+
* Derived type names may, but need not, end with `...Type`.
20+
* If a source file exists primarily to host a module, name the source file and module identically, except for trailing `...Module`.
21+
* If a module exists primarily to host a type, name the module and type identically, except for trailing `...Module` and `...Type`.
22+
* Include the module/subroutine/function name in `end module`, `end subroutine` and `end function` statements.
23+
* Don't end procedures with a `return` statement; use `return` only to return early.
24+
* Avoid `goto` statements.
25+
* Use `implicit none` in all modules.
26+
* Avoid `implicit none` in procedures except where necessary (e.g. interface bodies).
27+
* Don't use implicit dummy arguments or local variables.
28+
* Make modules `private` by default. Mark `public` types and procedures explicitly.
29+
* Specify precision for logicals, integers and reals with the data types defined in `src/Utilities/kind.f90`.
30+
* Avoid empty comments.
31+
* Avoid comments starting with `--`.
32+
* Include blank lines between:
33+
* module declaration and `use...` statements
34+
* `use...` statements and procedure declarations
35+
* derived type declaration and member variables
36+
* member variables and `contains` statements
37+
* Prefer explicitly specified imports with `use ..., only: ...`, rather than merely `use ...`.
38+
* Prefer importing items used throughout a module with a module-scoped `use` statement, rather than separately in multiple procedures.
39+
* 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.
40+
* Name type-bound procedures' first dummy argument `this`. A suitable docstring is `!< this instance`.
41+
* Avoid deeply nested control structures where possible.
42+
* Prefer verbose names, except where the meaning is obvious from context or precedent. E.g., well-known index variables (`i`, `j`, `m`, `n`).
43+
* Use named constants. Avoid [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)).
44+
45+
## Sample Module
46+
47+
Below is a minimal module demonstrating some (but not all) of the conventions.
48+
49+
```f90
50+
module SampleModule
51+
52+
use KindModule, only: DP, I4B, LGP
53+
use ConstantsModule, only: DPI
54+
55+
implicit none
56+
private
57+
public :: run_sample
58+
59+
contains
60+
61+
subroutine run_sample(verbose)
62+
logical(LGP), intent(in) :: verbose
63+
integer(I4B) :: answer
64+
real(DP) :: pi
65+
66+
answer = 42
67+
pi = DPI
68+
69+
if (verbose) then
70+
print *, 'pi: ', pi
71+
print *, 'answer to the ultimate question of life,'&
72+
' the universe, and everything: ', answer
73+
end if
74+
end subroutine run_sample
75+
76+
end module SampleModule
77+
```

.doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
# -- Project information -----------------------------------------------------
5050

51-
project = "MODFLOW 6 Program Documentation"
52-
copyright = "2023, MODFLOW Development Team"
51+
project = "MODFLOW 6"
52+
copyright = "2024, MODFLOW Development Team"
5353
author = "MODFLOW Development Team"
5454

5555
# -- General configuration ---------------------------------------------------

.github/common/update_fortran_style.py

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)