cl-dot icon indicating copy to clipboard operation
cl-dot copied to clipboard

Proposed modification of cl-dot:dot-graph

Open ko56 opened this issue 3 years ago • 6 comments

This modification automatically assigns to the output file a suffix dictated by the format, as indicated in the last line of the comment. So you can simply say (dot-graph g :pdf) or (dot-graph g :svg), etc, and the output file will be g.pdf, g.svg, etc.

(defun dot-graph (graph outfile &key (format :ps) (directed t))
  "Renders GRAPH to OUTFILE by running the program in \*DOT-PATH* or
*NEATO-PATH* depending on the value of the DIRECTED keyword
argument.  The default is a directed graph.  The default
FORMAT is Postscript. 
The output file is assigned a suffix based on the FORMAT."
  (when (null format) (setf format :ps))
  (setf outfile (uiop:strcat (namestring outfile) "." (string-downcase format)))
  (let ((dot-path (if directed *dot-path* *neato-path*))
         (format (format nil "-T~(~a~)" format))
         (dot-string (with-output-to-string (stream)
		       (print-graph graph :stream stream :directed directed))))
    (uiop:run-program (list dot-path format "-o" outfile)
      :input (make-string-input-stream dot-string) :output *standard-output*))) 

ko56 avatar Jul 05 '22 12:07 ko56

To do this properly, instead of concatenating strings (which could lead to, e.g., g.pdf.pdf), should use merge-pathnames, something like:

(setf outfile (merge-pathnames (parse-namestring outfile) (make-pathname :type (string-downcase format))))

that will not overwrite or append to user-supplied filename suffix.

rpgoldman avatar Dec 20 '23 15:12 rpgoldman

OK, agreed with the above. What's the next step?

ko56 avatar Jan 05 '24 00:01 ko56

OK, agreed with the above. What's the next step?

Next step would be to make the proposed change in your branch and push the change. Then we can merge it.

After that, the next step is to figure out who has the commit bit on this repo and get it merged.

rpgoldman avatar Jan 05 '24 15:01 rpgoldman

Ah, I see:

  1. The next step is to make a Merge Request for this
  2. I'll review and -- it seems I have the commit bit -- I will merge the MR.

rpgoldman avatar Jan 05 '24 15:01 rpgoldman

I'm trying to make a merge request, but not succeeding. According to what I see on the web, clicking on "Pull requests" at the top of this page should take you to a page at whose bottom you should find an option to merge. But if I follow this, I don't see such an option. Maybe I'm completely off-base here, git is not my friend :-)

ko56 avatar Jan 05 '24 17:01 ko56

I'm trying to make a merge request, but not succeeding. According to what I see on the web, clicking on "Pull requests" at the top of this page should take you to a page at whose bottom you should find an option to merge. But if I follow this, I don't see such an option. Maybe I'm completely off-base here, git is not my friend :-)

I think you should be able to navigate to the file you want to fix, and then choose the edit option. I believe that this will force you to fork the repo to your own GitHub account (which is fine). Do that, edit the file, commit it, and then you should be able to create a merge request.

rpgoldman avatar Jan 08 '24 16:01 rpgoldman

I think this is fixed now.

rpgoldman avatar Feb 21 '24 20:02 rpgoldman