Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modern Fortran comment style #836

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -44,6 +44,7 @@ CLI command and its behaviour. There are no guarantees of stability for the

- 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 @@ -341,14 +342,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 @@ -562,15 +572,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