mathlibtools/lib.py
def list_decls(self) -> Dict[str, DeclInfo]:
        """Collect declarations seen from this project, as a dictionary of
        DeclInfo"""
        all_exists = (self.src_directory/'all.lean').exists()
        list_decls_lean = self.src_directory/'list_decls.lean'
        try:
            list_decls_lean.unlink()
        except FileNotFoundError:
            pass

        log.info('Gathering imports')
        self.make_all()
        imports = (self.src_directory/'all.lean').read_text()
        decls_lean = (Path(__file__).parent/'decls.lean').read_text()
        list_decls_lean.write_text(imports+decls_lean)
        log.info('Collecting declarations')
        self.run_echo(['lean', '--run', str(list_decls_lean)])
        data = yaml.safe_load((self.directory/'decls.yaml').open())
        list_decls_lean.unlink()
        if not all_exists:
            (self.src_directory/'all.lean').unlink()
        decls = dict()
        for name, val in data.items():
            fname = val['File']
            line = val['Line']
            if fname is None or line is None:
                continue
            path = Path(fname).absolute().resolve()
            if '_target' in fname:
                path = path.relative_to(self.directory/'_target'/'deps')
                origin = path.parts[0]
                path = path.relative_to(Path(origin)/'src')
            elif '.elan' in fname:
                origin = 'core'
                parts = path.parts
                path = Path('/'.join(parts[parts.index('.elan')+7:]))
            else:
                origin = self.name
                path = path.relative_to(self.src_directory)
            decls[name] = DeclInfo(origin, path, int(val['Line']))

        return decls
Collect declarations seen from this project, as a dictionary of
        DeclInfo
Collect declarations seen from this project, as a dictionary of
DeclInfo
Collect declarations seen from this project as a dictionary of DeclInfo
def list_decls(self) -> Dict[str, DeclInfo]:
        all_exists = (self.src_directory/'all.lean').exists()
        list_decls_lean = self.src_directory/'list_decls.lean'
        try:
            list_decls_lean.unlink()
        except FileNotFoundError:
            pass
        log.info('Gathering imports')
        self.make_all()
        imports = (self.src_directory/'all.lean').read_text()
        decls_lean = (Path(__file__).parent/'decls.lean').read_text()
        list_decls_lean.write_text(imports+decls_lean)
        log.info('Collecting declarations')
        self.run_echo(['lean', '--run', str(list_decls_lean)])
        data = yaml.safe_load((self.directory/'decls.yaml').open())
        list_decls_lean.unlink()
        if not all_exists:
            (self.src_directory/'all.lean').unlink()
        decls = dict()
        for name, val in data.items():
            fname = val['File']
            line = val['Line']
            if fname is None or line is None:
                continue
            path = Path(fname).absolute().resolve()
            if '_target' in fname:
                path = path.relative_to(self.directory/'_target'/'deps')
                origin = path.parts[0]
                path = path.relative_to(Path(origin)/'src')
            elif '.elan' in fname:
                origin = 'core'
                parts = path.parts
                path = Path('/'.join(parts[parts.index('.elan')+7:]))
            else:
                origin = self.name
                path = path.relative_to(self.src_directory)
            decls[name] = DeclInfo(origin, path, int(val['Line']))
        return decls
def list_decls ( self ) -> Dict [ str , DeclInfo ] : all_exists = ( self . src_directory / 'all.lean' ) . exists ( ) list_decls_lean = self . src_directory / 'list_decls.lean' try : list_decls_lean . unlink ( ) except FileNotFoundError : pass log . info ( 'Gathering imports' ) self . make_all ( ) imports = ( self . src_directory / 'all.lean' ) . read_text ( ) decls_lean = ( Path ( __file__ ) . parent / 'decls.lean' ) . read_text ( ) list_decls_lean . write_text ( imports + decls_lean ) log . info ( 'Collecting declarations' ) self . run_echo ( [ 'lean' , '--run' , str ( list_decls_lean ) ] ) data = yaml . safe_load ( ( self . directory / 'decls.yaml' ) . open ( ) ) list_decls_lean . unlink ( ) if not all_exists : ( self . src_directory / 'all.lean' ) . unlink ( ) decls = dict ( ) for name , val in data . items ( ) : fname = val [ 'File' ] line = val [ 'Line' ] if fname is None or line is None : continue path = Path ( fname ) . absolute ( ) . resolve ( ) if '_target' in fname : path = path . relative_to ( self . directory / '_target' / 'deps' ) origin = path . parts [ 0 ] path = path . relative_to ( Path ( origin ) / 'src' ) elif '.elan' in fname : origin = 'core' parts = path . parts path = Path ( '/' . join ( parts [ parts . index ( '.elan' ) + 7 : ] ) ) else : origin = self . name path = path . relative_to ( self . src_directory ) decls [ name ] = DeclInfo ( origin , path , int ( val [ 'Line' ] ) ) return decls
Collect declarations seen from this project, as a dictionary of
DeclInfo
Collect declarations seen from this project as a dictionary of DeclInfo
"""Collect declarations seen from this project, as a dictionary of
        DeclInfo"""
self