-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Add reStructedText support #2564
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2564 +/- ##
==========================================
+ Coverage 27.33% 27.38% +0.04%
==========================================
Files 86 87 +1
Lines 17137 17157 +20
==========================================
+ Hits 4684 4698 +14
- Misses 11775 11780 +5
- Partials 678 679 +1
Continue to review full report at Codecov.
|
057ce9d to
de1bdb8
Compare
|
Tests added and rebased. |
|
LGTM |
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.
Why gogits/gogs?
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.
Shouldn't settings be set to previous value at the end of test to avoid affecting other tests? I think simple defer can be used for that.
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.
Create test as separate function so you can use it for both tests.
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.
reners - typo? I think you can remove string from the end of comment.
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.
Is not rawbytes in comment redudant? And should be unified with RenderString comment.
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 think function comment should tell what that function is doing, not which interface it fulfils.
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.
Same as for Name()
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.
Same as above.
de1bdb8 to
249fec3
Compare
|
@Morlinest all done. |
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.
IMO, using a third-party library that is "experimental/highly under development" (README) is not a good idea. Would it be worth finding a more stable library, or waiting until this one becomes more mature?
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.
w.Flush() returns an error
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.
done.
|
@ethantkoenig Yes, but this is the most mature library I can find. Also, if #2570 could be merged, external tool could override internal library. |
f9e945b to
6a4f0f8
Compare
| defer func() { | ||
| setting.AppURL = appURL | ||
| setting.AppSubURL = appSubURL | ||
| }() |
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 think you can simplify it like this:
defer func(appURL, appSubURL string) {
setting.AppURL = appURL
setting.AppSubURL = appSubURL
}(setting.AppURL, setting.AppSubURL)
or to use same deffer for both tests:
func resetSetings(appURL, appSubURL string) {
setting.AppURL = appURL
setting.AppSubURL = appSubURL
}
...
defer resetSetings(setting.AppURL, setting.AppSubURL)
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.
Now, when I look at whole change at once... Why you need to change settings? I see only setting.AppSubURL is used in test().
| const AppSubURL = AppURL + Repo + "/" | ||
|
|
||
| func test(t *testing.T, input, expected string) { | ||
| buffer := RenderString(input, setting.AppSubURL, nil, false) |
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.
Use setting.AppSubURL as another test() argument. E.g. test(t *testing.T, input, expected, appSubURL string)
|
|
||
| const AppURL = "http://localhost:3000/" | ||
| const Repo = "go-gitea/gitea" | ||
| const AppSubURL = AppURL + Repo + "/" |
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.
If you don't need all constants (look at comment for defer), merge them together. Also I think you can use unexported version. E.g. const appSubURL = "http://localhost:3000/go-gitea/gitea/".
| `<p><a href="`+lnk+`">WikiPage</a></p>`)*/ | ||
| } | ||
|
|
||
| func TestRender_Images(t *testing.T) { |
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.
If you don' need to change settings (look at defer comment above), you can merge both tests together, remove setting variable changes and defer and use t.Run() (just create array of test cases) to run tests in parallel.
ethantkoenig
left a comment
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 still do not think that using an unstable library is a good idea, but I'll approve so that I don't block the PR.
|
@ethantkoenig I don't mind to put this PR later. If #2570 could be merged, it also resolved #374. |
|
And maybe https://github.com/demizer/go-rst is a better choice. |
should be part of #374, see below screenshots.