code: def from_file(cls, filename, directory=None,
                    format=None, engine=None, encoding=File._encoding):
          
          filepath = os.path.join(directory or '', filename)
          if encoding is None:
              encoding = locale.getpreferredencoding()
          with io.open(filepath, encoding=encoding) as fd:
              source = fd.read()
          return cls(source, filename, directory, format, engine, encoding)
docs: Return an instance with the source string read from the given file.
  
          Args:
              filename: Filename for loading/saving the source.
              directory: (Sub)directory for source loading/saving and rendering.
              format: Rendering output format (``'pdf'``, ``'png'``, ...).
              engine: Layout command used (``'dot'``, ``'neato'``, ...).
              encoding: Encoding for loading/saving the source.