- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 170
Refactor to make sphinx a soft dependency #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            rossbar
  wants to merge
  12
  commits into
  numpy:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
rossbar:soft-sphinx
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            12 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8a51c0a
              
                DEP: Mv sphinx dep to optional.
              
              
                rossbar fb070f9
              
                MAINT: Make app setup optional in __init__.
              
              
                rossbar effcf01
              
                TST: Split docscrape tests based on sphinx dep.
              
              
                rossbar a380d08
              
                TST: Reuse test inputs in test_docscrape_sphinx.py.
              
              
                rossbar 4d3b301
              
                TST: Skip test_full if no sphinx installed.
              
              
                rossbar 530d580
              
                MAINT: split _clean_text_signature out to _utils.
              
              
                rossbar 4bebfdd
              
                TST: Configure test collection per sphinx availability
              
              
                rossbar 8283bd1
              
                DEP: Break numpydoc.cli dependence on sphinx.
              
              
                rossbar f27d289
              
                Update numpydoc/cli.py
              
              
                rossbar 7708ca0
              
                TST: Fix hook tests for windows.
              
              
                rossbar b31376a
              
                Lint.
              
              
                rossbar 09cfe96
              
                Update pyproject.toml
              
              
                rossbar File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Configure test collection to skip doctests for modules that depend on sphinx | ||
| # when sphinx is not available in the environment. | ||
|  | ||
| try: | ||
| import sphinx | ||
|  | ||
| has_sphinx = True | ||
| except ImportError: | ||
| has_sphinx = False | ||
|  | ||
|  | ||
| collect_ignore = [] | ||
|  | ||
| if not has_sphinx: | ||
| collect_ignore += ["numpydoc/numpydoc.py", "numpydoc/docscrape_sphinx.py"] | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import re | ||
|  | ||
|  | ||
| def _clean_text_signature(sig): | ||
| if sig is None: | ||
| return None | ||
| start_pattern = re.compile(r"^[^(]*\(") | ||
| start, end = start_pattern.search(sig).span() | ||
| start_sig = sig[start:end] | ||
| sig = sig[end:-1] | ||
| sig = re.sub(r"^\$(self|module|type)(,\s|$)", "", sig, count=1) | ||
| sig = re.sub(r"(^|(?<=,\s))/,\s\*", "*", sig, count=1) | ||
| return start_sig + sig + ")" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is necessary. What about including
numpydoc[default]in our test dependencies and then we can test everything?Alternatively, what about marking the tests that require sphinx as expected fails when sphinx isn't available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would work for CI but wouldn't work out-of-the-box for a development environment. I personally think there's value in being able to run only the tests (including doctests) for the non-sphinxy bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth using nox if we want that because now we are talking about needing to use two different virtual environments to run the tests like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm -1 on more tooling for testing/environment management. All this change does is introduce
importorskip-like behavior for doctests as well to ensure that the "full" test suite (i.e. including doctests) runs the correct tests whether or not sphinx is installed.