numpy / numpydoc

Numpy's Sphinx extensions
https://numpydoc.readthedocs.io/
Other
294 stars 160 forks source link

Errors result in huge, verbose output #52

Closed mpharrigan closed 7 years ago

mpharrigan commented 8 years ago

It seems when there's an error in sphinx, you get a printout of the following form

path/to/filename.rst:77: ERROR: Unknown target name: "children".

When an error occurs in a numpydoc-ed class, the filename part is replaced with a representation of a python list of all the lines (in rst-form, post numpydoc mangling) which can be quite long. It fills up my bash history and makes it incredibly hard to see the actual error message.

['n_components_  (int) The estimated number of connected components in the graph.  ', '    children_  (array-like, shape (n_nodes-1, 2)) The children of each non-leaf node. Values less than `n_samples` correspond to leaves of the tree which are the original samples. A node `i` greater than or equal to `n_samples` is a non-leaf node and has children `children_[i - n_samples]`. Alternatively at the i-th iteration, children[i][0] and children[i][1] are merged to form node `n_samples + i`  ', '=============  ==========', '', '.. rubric:: Methods', '', '.. autosummary::', '', '   fit', '   fit_predict', '   fit_transform', '   get_params', '   partial_predict', '   partial_transform', '   predict', '   set_params', '   summarize', '   transform', '', '.. automethod:: __init__', '', '', '.. rubric:: Methods', '', '.. autosummary::', '', '   ~Ward.__init__', '   ~Ward.fit', '   ~Ward.fit_predict', '   ~Ward.fit_transform', '   ~Ward.get_params', '   ~Ward.partial_predict', '   ~Ward.partial_transform', '   ~Ward.predict', '   ~Ward.set_params', '   ~Ward.summarize', '   ~Ward.transform', '', '.. py:method:: Ward.fit(sequences, y=None)', '   :module: msmbuilder.cluster', '', '   ', '   ', '   Fit the  clustering on the data', '   ', '   ', '   :Parameters:', '   ', '       **sequences** : list of array-like, each of shape [sequence_length, n_features]', '   ', '           A list of multivariate timeseries. Each sequence may have', '           a different length, but they all must have the same number', '           of features.', '   ', '   :Returns:', '   ', '       self', '   ', '           ', '   ', '', '.. py:method:: Ward.fit_predict(sequences, y=None)', '   :module: msmbuilder.cluster', '', '   ', '   ', '   Performs clustering on X and returns cluster labels.', '   ', '   ', '   :Parameters:', '   ', '       **sequences** : list of array-like, each of shape [sequence_length, n_features]', '   ', '           A list of multivariate timeseries. Each sequence may have', '           a different length, but they all must have the same number', '           of features.', '   ', '   :Returns:', '   ', '       **Y** : list of ndarray, each of shape [sequence_length, ]', '   ', '           Cluster labels', '   ', '', '.. py:method:: Ward.fit_transform(sequences, y=None)', '   :module: msmbuilder.cluster', '', '   ', '   ', '   Alias for fit_predict', '   ', '   ', '', '.. py:method:: Ward.get_params(deep=True)', '   :module: msmbuilder.cluster', '', '   ', '   ', '   Get parameters for this estimator.', '   ', '   ', '   :Parameters:', '   ', '       **deep: boolean, optional**', '   ', '           If True, will return the parameters for this estimator and', '           contained subobjects that are estimators.', '   ', '   :Returns:', '   ', '       **params** : mapping of string to any', '   ', '           Parameter names mapped to their values.', '   ', '', '.. py:method:: Ward.partial_predict(X, y=None)', '   :module: msmbuilder.cluster', '', '   ', '   ', '   Predict the closest cluster each sample in X belongs to.', '   ', '   In the vector quantization literature, `cluster_centers_` is called', '   the code book and each value returned by `predict` is the index of', '   the closest code in the code book.', '   ', '   :Parameters:', '   ', '       **X** : array-like shape=(n_samples, n_features)', '   ', '           A single timeseries.', '   ', '   :Returns:', '   ', '       **Y** : array, shape=(n_samples,)', '   ', '           Index of the cluster that each sample belongs to', '   ', '', '.. py:method:: Ward.partial_transform(X)', '   :module: msmbuilder.cluster', '', '   ']:77: ERROR: Unknown target name: "children".

Can anyone point me to where I might investigate where this filename is getting (re-)set?

amueller commented 8 years ago

Also see https://github.com/sphinx-doc/sphinx/issues/2940

And minimum example here: https://github.com/amueller/sphinx_autodoc_debug

This is really really bad :(

@mpharrigan do you actually have that with static rest files? I only had this problem with autodoc, I think.

amueller commented 8 years ago

I think the problem is here: https://github.com/numpy/numpydoc/blob/master/numpydoc/numpydoc.py#L202