Skip to content

Commit

Permalink
Merge branch 'master' into fix-call-chain-external-types
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree authored Nov 9, 2023
2 parents 6460dac + cd71a3f commit 45b8dd2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ def main(proj_data: ProjectSettings, proj_docs: str):

base_url = ".." if proj_data.relative else proj_data.project_url

print(" Correlating information from different parts of your project...", end="")
print(" Correlating information from different parts of your project...")
correlate_time_start = time.time()
project.correlate()
correlate_time_end = time.time()
print(f" done in {correlate_time_end - correlate_time_start:5.3f}s")
print(f" ...done in {correlate_time_end - correlate_time_start:5.3f}s")

# Setup Markdown object with any user-specified extensions
aliases = copy.copy(proj_data.alias)
Expand Down
18 changes: 10 additions & 8 deletions ford/fortran_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ def namelist_check(entity):

self.files.append(new_file)

def warn(self, message):
if self.settings.warn:
warn(f"{message}")

@property
def allfiles(self):
"""Instead of duplicating files, it is much more efficient to create the itterator on the fly"""
Expand Down Expand Up @@ -298,14 +294,20 @@ def filter_modules(entity) -> List[FortranModule]:

for mod in self.submodules:
if type(mod.ancestor_module) is not FortranModule:
self.warn(
f"Could not identify ancestor MODULE of SUBMODULE '{mod.name}'. "
warn(
f"Could not identify ancestor module ('{mod.ancestor_module}') of submodule '{mod.name}' "
f"(in '{mod.filename}').\n"
f" This is usually because Ford hasn't found '{mod.ancestor_module}' "
"in any of the source directories.\n"
)
continue

if not isinstance(mod.parent_submodule, (FortranSubmodule, type(None))):
self.warn(
f"Could not identify parent SUBMODULE of SUBMODULE '{mod.name}'"
warn(
f"Could not identify parent submodule ('{mod.parent_submodule}') of submodule '{mod.name}' "
f"(in '{mod.filename}').\n"
f" This is usually because Ford hasn't found '{mod.parent_submodule}' "
"in any of the source directories.\n"
)

mod.deplist = [
Expand Down
16 changes: 14 additions & 2 deletions ford/sourceform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,8 +1450,9 @@ def get_label_item(context, label):
# extended type
extend_type = context
while extend_type := getattr(extend_type, "extends", None):
name = getattr(extend_type, "name", "").lower()
labels[name] = extend_type
if isinstance(extend_type, str):
break
labels[extend_type.name.lower()] = extend_type
# vars
labels.update(getattr(context, "all_vars", {}))
# local vars
Expand Down Expand Up @@ -1585,6 +1586,7 @@ def _initialize(self, line: re.Match) -> None:
self.private_list: List[str] = []
self.protected_list: List[str] = []
self.visible = True
self.deplist: List[FortranModule] = []

def _cleanup(self):
"""Create list of all local procedures. Ones coming from other modules
Expand Down Expand Up @@ -1983,6 +1985,16 @@ def correlate(self, project):
# Match variables as needed (recurse)
for v in self.variables:
v.correlate(project)

if self.extends and isinstance(self.extends, str):
warn(
f"Could not find base type ('{self.extends}') of derived type '{self.name}' "
f"(in '{self.filename}').\n"
f" If '{self.extends}' is defined in an external module, you may be "
"able to tell Ford about its documentation\n"
" with the `extra_mods` setting"
)

# Get inherited public components
inherited = [
var
Expand Down
13 changes: 11 additions & 2 deletions ford/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
#

import re
import os
import os.path
import pathlib
from types import TracebackType
from typing import Dict, Union, List, Any, Tuple, Optional, Sequence, cast, Sized, Type
from typing import Dict, Union, List, Any, Tuple, Optional, Iterable, cast, Sized, Type
from io import StringIO
import itertools
from collections import defaultdict
Expand Down Expand Up @@ -293,14 +294,21 @@ class ProgressBar:
def __init__(
self,
description: str,
iterable: Optional[Sequence] = None,
iterable: Optional[Iterable] = None,
total: Optional[int] = None,
):
if total is None and hasattr(iterable, "__len__"):
self._total: Optional[int] = len(cast(Sized, iterable))
else:
self._total = total

# rich `Progress` breaks `pdb` and `breakpoint`, see:
# - https://github.com/Textualize/rich/issues/1053
# - https://github.com/Textualize/rich/issues/1465
# and maintainer seems uninterested in fixing. So, workaround
# by setting an env var to disable progress bar entirely
disable: bool = bool(os.environ.get("FORD_DEBUGGING", False))

self._iterable = iterable
self._progress = Progress(
SpinnerColumn(),
Expand All @@ -312,6 +320,7 @@ def __init__(
TimeElapsedColumn(),
TextColumn("{task.fields[current]}"),
console=console,
disable=disable,
)

self._progress.start()
Expand Down

0 comments on commit 45b8dd2

Please sign in to comment.