Comments (6)
Hi @CagtayFabry, thanks for your interest in reprexlite!
Can you explain a little bit more about why you want to use reprexlite for doctest outputs? One of the core design ideas behind reprexlite is to be an alternative to doctest. Even if this weren't the case, it's also not clear to me that something like reprexlite is the right tool for this. You could simply open a Python REPL from the command line and copy-paste from there.
from reprexlite.
thanks for getting back here @jayqi
basically I currently use reprexlite
for a convenient way to produce examples/bug reports etc. for GH. I usually generate those from a jupyter environment. Some of my projects rely on doctest for docstrings and testing.
The main benefits I could see in using reprexlite
for creating doctest-like output over running code in an iPython shell are:
- better handling of multiline scripts with multiple outputs at the correct line (without adding
print
etc.) - ability to
black
-format the input - stick to a notebook environment to generate both (GH format + doctest)
I do agree on your assessment of the drawbacks when using doctest format but I need the sphinx/pytest integration etc.
from reprexlite.
I guess that makes sense.
I think rather than a --venue=doctest
, it probably makes more sense to implement it through different parameters, since you might want doctest-style output in any of the venues. Discussion of two possible approaches to implementation:
- Have some kind of switch
--style=reprex
or--style=doctest
.- This might not be the right abstraction since the
--comment
option doesn't make as much sense in this context.
- This might not be the right abstraction since the
- Add prompt parameter(s) that you can set to
>>>
(and maybe also...
for multiline). Figure out how to set--comment
to empty string.- This seems like it would be the most general approach, and would be able to support doctest as well as whatever other styles that someone cooks up.
Another angle to your use case is maybe open issue #16. I'm not sure how sphinx or pytest handle doctests so I don't know much on top of that it would take to support sphinx or pytest.
from reprexlite.
I did poke around at this and made some progress. It does involve a bunch of refactoring as it doesn't quite line up with some of my abstractions. 😅
One annoying thing still to solve is that libcst, which I use to parse the code, attaches whitespace lines to code statements following them, which ends up misformatting the code after empty lines. That will involve some finagling.
>>> from itertools import product
>>>
... grid = list(product([1, 2, 3], [8, 16]))
>>> grid
[(1, 8), (1, 16), (2, 8), (2, 16), (3, 8), (3, 16)]
>>> for var in list(zip(*grid)):
... print(var)
(1, 1, 2, 2, 3, 3)
(8, 16, 8, 16, 8, 16)
from reprexlite.
Hi @CagtayFabry,
I know it's been a while, but I did a major overhaul of reprexlite's internals and this has been merged to the main branch. It's not released yet, but if you want to start using it, you can install from source.
reprex --prompt=">>>" --continuation="..." --comment=""
>>> from itertools import product
>>>
>>> grid = list(product([1, 2, 3], [8, 16]))
>>> grid
[(1, 8), (1, 16), (2, 8), (2, 16), (3, 8), (3, 16)]
>>> list(zip(*grid))
[(1, 1, 2, 2, 3, 3), (8, 16, 8, 16, 8, 16)]
Created at 2023-02-22 19:55:25 EST by reprexlite v1.0.0
from reprexlite.
awesome! 🚀
these configuration options look great! thank you for the ping @jayqi
from reprexlite.
Related Issues (20)
- Failed build on main branch (tests #158)
- Failed build on main branch (tests #159)
- Failed build on main branch (tests #160)
- Failed build on main branch (tests #173) HOT 2
- Failed build on main branch (tests #180)
- Failed build on main branch (tests #181) HOT 1
- Failed build on main branch (tests #182) HOT 1
- Failed build on main branch (tests #186) HOT 1
- Failed build on main branch (tests #187) HOT 1
- Failed build on main branch (tests #188) HOT 1
- Failed build on main branch (tests #189) HOT 1
- Failed build on main branch (tests #190) HOT 1
- Failed build on main branch (tests #191) HOT 1
- Failed build on main branch (tests #192) HOT 1
- Failed build on main branch (tests #193) HOT 1
- Failed build: tests HOT 13
- Detect light/dark terminal theme and use appropriate colors
- Failed build: Codecov upload problem HOT 1
- Failed build: tests HOT 1
- Failed build: tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reprexlite.