Skip to content

Commit

Permalink
Merge pull request #836 from dbroemmel/main
Browse files Browse the repository at this point in the history
Add modern Fortran comment style
  • Loading branch information
carmenbianca committed Oct 24, 2023
2 parents 0e64bda + b64709f commit ecd09f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Contributors

- Shun Sakai

- Dirk Brömmel

Translators
-----------

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CLI command and its behaviour. There are no guarantees of stability for the
- Declared support for Python 3.12. (#846)
- More file types are recognised:
- Julia (`.jl`) (#815)
- Modern Fortran (`.f90`) (#836)

### Changed

Expand Down
21 changes: 17 additions & 4 deletions src/reuse/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# SPDX-FileCopyrightText: 2023 Kevin Meagher
# SPDX-FileCopyrightText: 2023 Mathias Dannesbo <md@magenta.dk>
# SPDX-FileCopyrightText: 2023 Shun Sakai <sorairolake@protonmail.ch>
# SPDX-FileCopyrightText: 2023 Juelich Supercomputing Centre, Forschungszentrum Juelich GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -348,14 +349,23 @@ def comment_at_first_character(cls, text: str) -> str:


class FortranCommentStyle(CommentStyle):
"""Fortran comment style."""
"""Fortran (fixed form) comment style."""

SHORTHAND = "f"

SINGLE_LINE = "c"
INDENT_AFTER_SINGLE = " "


class ModernFortranCommentStyle(CommentStyle):
"""Fortran (free form) comment style."""

SHORTHAND = "f90"

SINGLE_LINE = "!"
INDENT_AFTER_SINGLE = " "


class FtlCommentStyle(CommentStyle):
"""FreeMarker Template Language comment style."""

Expand Down Expand Up @@ -569,15 +579,18 @@ class XQueryCommentStyle(CommentStyle):
".ex": PythonCommentStyle,
".exs": PythonCommentStyle,
".f": FortranCommentStyle,
".f03": FortranCommentStyle,
".f90": FortranCommentStyle,
".f95": FortranCommentStyle,
".f03": ModernFortranCommentStyle,
".f08": ModernFortranCommentStyle,
".f90": ModernFortranCommentStyle,
".f95": ModernFortranCommentStyle,
".fish": PythonCommentStyle,
".fnl": LispCommentStyle,
".fodp": UncommentableCommentStyle,
".fods": UncommentableCommentStyle,
".fodt": UncommentableCommentStyle,
".for": FortranCommentStyle,
".ftn": FortranCommentStyle,
".fpp": FortranCommentStyle,
".fs": CCommentStyle,
".ftl": FtlCommentStyle,
".gemspec": PythonCommentStyle,
Expand Down

0 comments on commit ecd09f3

Please sign in to comment.