# Hiding the implementation of procedures

**URL:** <https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438>\
**Category:** Uncategorized\
**Created:** [November 22, 2020, 5:07pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438 "2020-11-22T17:07:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [November 22, 2020, 5:07pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/1 "2020-11-22T17:07:49Z")

</div>

Is there a text editor with a mode that will hide the implementation of a Fortran function or subroutine? For example if the function is

```
function abs_df(df) result(df_abs)
! return a date_time_frame_full with elements that are the absolute values of df
type(date_time_frame_full), intent(in) :: df
type(date_time_frame_full) :: df_abs
if (num_obs(df) < 1 .or. num_var(df) < 1) return
df_abs = df
df_abs%xx = abs(df%xx)
df_abs%title = "|" // trim(df%title) // "|"
end function abs_df

```

I want to display only the procedure arguments, the initial comment line, the function result, and the final line of the procedure, in this case

```
function abs_df(df) result(df_abs)
! return a date_time_frame_full with elements that are the absolute values of df
type(date_time_frame_full), intent(in) :: df
type(date_time_frame_full) :: df_abs
end function abs_df

```

If there is no text editor that does this, I may write a program to create source files with such stubs. I should be able to understand what a procedure does by looking at the stub, without seeing the full source. If not, it needs more initial comment lines.

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [November 22, 2020, 5:45pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/2 "2020-11-22T17:45:31Z")

</div>

I think [Geany](https://www.geany.org/) has something similar to this, but I don’t think it is able to recognize the data declaration section of a Fortran subprogram.

I checked how code folding works in MATLAB. It is possible to hide either the entire function, or the help string. But it doesn’t seem possible to hide the function while preserving the help string:

 ![matlab_code_folding](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/1X/d195c7a9f44c9bea498b35119182ee8718881238.png)

You could separate your Fortran procedures and put the interfaces into a module, and the implementations in a submodule. Then you can document your procedures in the module.

---

<div class="post-metadata">

**Author:** ![nshaffer](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nshaffer/32/161_2.png) [@nshaffer](https://fortran-lang.discourse.group/u/nshaffer)\
**Post date:** [November 22, 2020, 7:45pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/3 "2020-11-22T19:45:04Z")

</div>

This is very similar to what you’d get from a documentation tool like FORD or doxygen. The drawbacks that I can think of is that 1) they expect the documentation comments to have a particular style (but that is configurable) and 2) they produce html to be viewed in a browser rather than plain text to be viewed in your editor.

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [November 24, 2020, 8:26pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/4 "2020-11-24T20:26:35Z")

</div>

If you use `vim` check out the many fold methods it has. If you are careful about how you indent you can get what you want just with indent folding. You have to have a recent version of `vim` but you can fold based on syntax highlighting and hide comments, fold manually, fold based on regular expressions, indent, … you can customize it more than that but it requires scripting in a vim-specific format.

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [November 24, 2020, 9:29pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/5 "2020-11-24T21:29:26Z")

</div>

> [@Beliavsky](#):
>
> Is there a text editor with a mode that will hide the implementation of a Fortran function or subroutine? …

@Beliavsky,

As others have mentioned, the key feature you’re looking for is **customized code folding** in an editor/IDE.

Several of the environments such as Code::Blocks Fortran plug-in and Intel Fortran integration with Microsoft Visual Studio IDE already offer some basic facility toward code folding. Until you can find something that is customizable for your needs, you can consider a “poor” Fortranner’s solution using the BLOCK construct!

Here’s what it can look like in Visual Studio IDE on Windows:  
 ![vs](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/1X/f230c1b85363ebb37f2970e51b52b0d59f69b033.png)

And with Code::Blocks:

 ![cb](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/1X/1c81d5367053a9e8146b26270c46a9bae5c2ea9e.png)

---

<div class="post-metadata">

**Author:** ![andrew\_4619](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@andrew\_4619](https://fortran-lang.discourse.group/u/andrew_4619)\
**Post date:** [November 28, 2020, 7:55pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/6 "2020-11-28T19:55:55Z")

</div>

You can configure your own syntax and folds in notepad++. You could set a code comment such as !ENDFOLD as a target.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [December 25, 2020, 8:48pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/7 "2020-12-25T20:48:30Z")

</div>

> [@nshaffer](#):
>
> This is very similar to what you’d get from a documentation tool like FORD or doxygen. The drawbacks that I can think of is that 1) they expect the documentation comments to have a particular style (but that is configurable) and 2) they produce html to be viewed in a browser rather than plain text to be viewed in your editor.

I have installed FORD and run it on a toy program. It would work great on my actual code, except that it recognizes comments only with !! and not a single exclamation mark. It [says](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Writing-Documentation) “the character(s) designating documentation can be changed”, but I don’t see how to do this.

---

<div class="post-metadata">

**Author:** ![rcs](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rcs](https://fortran-lang.discourse.group/u/rcs)\
**Post date:** [December 26, 2020, 7:18am UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/8 "2020-12-26T07:18:08Z")

</div>

If you are familiar with emacs you can use the built in “outline” functionality.

---

<div class="post-metadata">

**Author:** ![nshaffer](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nshaffer/32/161_2.png) [@nshaffer](https://fortran-lang.discourse.group/u/nshaffer)\
**Post date:** [December 26, 2020, 4:10pm UTC](https://fortran-lang.discourse.group/t/hiding-the-implementation-of-procedures/438/9 "2020-12-26T16:10:04Z")

</div>

You can customize the character that comes after `!` to mark documentation, e.g., `docmark: +` I believe should make `!+` the documentation maker. It’s an option you can set in the project file.

> **[Fortran-FOSS-Programmers/ford](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Project-File-Options)**
>
> Project-File-Options

(See “docmark”)

I do not know if it is possible to make a single `!` treated as a documentation comment.
