2323class JSONVisitor :
2424 """Node visitor that creates a JSON-serializable structure."""
2525 def __init__ (self ,
26- project_root : Path ,
26+ source_path : Path ,
2727 docpath : PurePath ,
2828 document : docutils .nodes .document ) -> None :
29- self .project_root = project_root
29+ self .source_path = source_path
3030 self .docpath = docpath
3131 self .document = document
3232 self .state : List [Dict [str , Any ]] = []
@@ -163,7 +163,6 @@ def handle_directive(self, node: docutils.nodes.Node, doc: Dict[str, Serializabl
163163 static_asset = self .add_static_asset (Path (argument_text ))
164164 options ['checksum' ] = static_asset .checksum
165165 except OSError as err :
166- print (util .get_line (node ))
167166 msg = '"figure" could not open "{}": {}' .format (
168167 argument_text , os .strerror (err .errno ))
169168 self .diagnostics .append (Diagnostic .error (msg , util .get_line (node )))
@@ -172,7 +171,7 @@ def handle_directive(self, node: docutils.nodes.Node, doc: Dict[str, Serializabl
172171 doc ['options' ] = options
173172
174173 def add_static_asset (self , path : Path ) -> StaticAsset :
175- fileid , path = util .reroot_path (path , self .docpath , self .project_root )
174+ fileid , path = util .reroot_path (path , self .docpath , self .source_path )
176175 static_asset = StaticAsset .load (fileid .as_posix (), path )
177176 self .static_assets .add (static_asset )
178177 return static_asset
@@ -181,7 +180,7 @@ def add_diagnostics(self, diagnostics: Iterable[Diagnostic]) -> None:
181180 self .diagnostics .extend (diagnostics )
182181
183182 def __make_child_visitor (self ) -> 'JSONVisitor' :
184- visitor = type (self )(self .project_root , self .docpath , self .document )
183+ visitor = type (self )(self .source_path , self .docpath , self .document )
185184 visitor .diagnostics = self .diagnostics
186185 return visitor
187186
@@ -253,13 +252,13 @@ def __init__(self,
253252 root : Path ,
254253 backend : ProjectBackend ) -> None :
255254 root = root .resolve (strict = True )
256- root , self .config , config_diagnostics = ProjectConfig .open (root )
255+ self .config , config_diagnostics = ProjectConfig .open (root )
257256
258257 if config_diagnostics :
259- backend .on_diagnostics (root , config_diagnostics )
258+ backend .on_diagnostics (self . config . root , config_diagnostics )
260259 raise ProjectConfigError ()
261260
262- self .root = root
261+ self .root = self . config . source_path
263262 self .parser = rstparser .Parser (self .config , JSONVisitor )
264263 self .static_assets : Dict [PurePath , Set [StaticAsset ]] = collections .defaultdict (set )
265264 self .backend = backend
0 commit comments