DOC handle more cases in getting doc source URL (ported from scipy)