A factory function for building a ReferenceResolver from a visitor. Args: visitor: an instance of `DocGeneratorVisitor` doc_index: a dictionary mapping document names to references objects with "title" and "url" fields **kwargs: all remaining args are passed to the con
(cls, visitor, doc_index, **kwargs)
| 201 | |
| 202 | @classmethod |
| 203 | def from_visitor(cls, visitor, doc_index, **kwargs): |
| 204 | """A factory function for building a ReferenceResolver from a visitor. |
| 205 | |
| 206 | Args: |
| 207 | visitor: an instance of `DocGeneratorVisitor` |
| 208 | doc_index: a dictionary mapping document names to references objects with |
| 209 | "title" and "url" fields |
| 210 | **kwargs: all remaining args are passed to the constructor |
| 211 | Returns: |
| 212 | an instance of `ReferenceResolver` () |
| 213 | """ |
| 214 | is_fragment = {} |
| 215 | for name, obj in visitor.index.items(): |
| 216 | has_page = ( |
| 217 | tf_inspect.isclass(obj) or tf_inspect.ismodule(obj) or |
| 218 | is_free_function(obj, name, visitor.index)) |
| 219 | |
| 220 | is_fragment[name] = not has_page |
| 221 | |
| 222 | return cls( |
| 223 | duplicate_of=visitor.duplicate_of, |
| 224 | doc_index=doc_index, |
| 225 | is_fragment=is_fragment, |
| 226 | **kwargs) |
| 227 | |
| 228 | @classmethod |
| 229 | def from_json_file(cls, filepath, doc_index): |