Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
405 stars 131 forks source link

Ensure proper data types for command line arguments to fix #601 #602

Closed haraldkl closed 9 months ago

haraldkl commented 9 months ago

The command line arguments also have to conform with the ProjectSettings data types. With these changes they are also passed through the converter that is also used for the MD meta data. I am not quite sure if this is the proper way to go about it, but it resolves #601 for me.

haraldkl commented 9 months ago

Looks like this fails the test "test_extra_mods_empty":

string_list = [''], name = 'extra_mods', sep = ':'

    def _parse_to_dict(string_list: List[str], name: str, sep: str) -> Dict[str, str]:
        """Parse a list of strings of form "key = value" into a dict

        Parameters
        ----------
        string_list : List[str]
            List of strings to parse
        name : str
            Name in parent settings object, only used for error message
        sep: str
            Separator between key and value

        """

        result = {}
        for string in string_list:
            try:
>               key, value = string.split(sep, 1)
E               ValueError: not enough values to unpack (expected 2, got 1)

/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/settings.py:430: ValueError
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/runner/work/ford/ford/test/test_md_inputs.py:22: in run_ford
    ford.run()
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/__init__.py:486: in run
    proj_data, proj_docs = initialize()
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/__init__.py:137: in initialize
    proj_docs, proj_data = load_settings(proj_docs, directory, args.project_file.name)
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/__init__.py:316: in load_settings
    proj_data, proj_docs = load_markdown_settings(directory, proj_docs, filename)
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/settings.py:312: in load_markdown_settings
    settings = convert_types_from_metapreprocessor(ProjectSettings, settings, filename)
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/settings.py:386: in convert_types_from_metapreprocessor
    settings[key] = convert_setting(default_type, key, value)
/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/site-packages/ford/settings.py:362: in convert_setting
    return _parse_to_dict(value, name=key, sep=sep)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
ZedThree commented 9 months ago

Thanks @haraldkl ! There was just a typo in the call to _parse_to_dict, I've fixed that and added a test to cover --external_links explicitly

haraldkl commented 9 months ago

Thanks a lot for the quick look into this, the fixes and merging!