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

Functions can also contain imports #606

Open
tristanlatr opened this issue Jun 17, 2022 · 0 comments
Open

Functions can also contain imports #606

tristanlatr opened this issue Jun 17, 2022 · 0 comments
Labels
astbuilder A substantive change is required in the astbuilder flow in order to fix this issue enhancement

Comments

@tristanlatr
Copy link
Contributor

Here's a test that is currently failing:

@pytest.mark.xfail
@systemcls_param
def test_links_function_docstring_imports_in_body(systemcls: Type[model.System]) -> None:
    
    mod = '''
    def expandName(name: str) -> str:
        """
        See L{names.expandName}
        """
        from pydoctor import names
        return names.expandName(name)
    '''
    
    _impl = '''
    def expandName(name: str) -> str:
        """Docs"""
        ...
    '''
    
    system = systemcls()
    builder = system.systemBuilder(system)
    builder.addModuleString('', modname='pydoctor', is_package=True)
    builder.addModuleString(mod, modname='pydoctor.model')
    builder.addModuleString(_impl, modname='pydoctor.names')
    builder.buildModules()

    fn = system.allobjects['pydoctor.model.expandName']

    assert fn.expandName('names.expandName') == 'pydoctor.names.expandName'

I believe we need the distinction between CanContainImport and CanContainDocumentable.

@tristanlatr tristanlatr added the astbuilder A substantive change is required in the astbuilder flow in order to fix this issue label Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astbuilder A substantive change is required in the astbuilder flow in order to fix this issue enhancement
Projects
None yet
Development

No branches or pull requests

1 participant