[PATCH] Fixing namespace edit (#319116)

View: New views
5 Messages — Rating Filter:   Alert me  

[PATCH] Fixing namespace edit (#319116)

by Mario Sopena Novales-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

    the attached path fices the problem with namespaces that cannot be
edited right now as states bug #319116.

Unfortunately, you must rebuild the docs to see it working, because
the editing infrastructure put some information on zip files for
editing which is not present for namespaces unless you rebuild the doc
with the patch.

May I commit it?

Reggards,  MarioS
_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@...
http://lists.ximian.com/mailman/listinfo/mono-docs-list

Re: [PATCH] Fixing namespace edit (#319116)

by Jonathan Pryor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2008-02-22 at 13:16 +0100, Mario Sopena Novales wrote:

> Hi,
>
>     the attached path fices the problem with namespaces that cannot be
> edited right now as states bug #319116.
>
> Unfortunately, you must rebuild the docs to see it working, because
> the editing infrastructure put some information on zip files for
> editing which is not present for namespaces unless you rebuild the doc
> with the patch.
>
> May I commit it?

Insert missing patch here.  :-)

 - Jon


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@...
http://lists.ximian.com/mailman/listinfo/mono-docs-list

Re: [PATCH] Fixing namespace edit (#319116)

by Mario Sopena Novales-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ups,

  ;-P

On 22/02/2008, Jonathan Pryor <jonpryor@...> wrote:

> On Fri, 2008-02-22 at 13:16 +0100, Mario Sopena Novales wrote:
>  > Hi,
>  >
>  >     the attached path fices the problem with namespaces that cannot be
>  > edited right now as states bug #319116.
>  >
>  > Unfortunately, you must rebuild the docs to see it working, because
>  > the editing infrastructure put some information on zip files for
>  > editing which is not present for namespaces unless you rebuild the doc
>  > with the patch.
>  >
>  > May I commit it?
>
>
> Insert missing patch here.  :-)
>
>   - Jon
>
>
>

[ns.diff]

Index: provider.cs
===================================================================
--- provider.cs (revisión: 96411)
+++ provider.cs (copia de trabajo)
@@ -609,9 +609,13 @@
  }
  }
 
- public void PackXml (string fname, XmlDocument doc)
+ public void PackXml (string fname, XmlDocument doc, string real_path)
  {
- zip_output.PutNextEntry (new ZipEntry (fname));
+        ZipEntry entry = new ZipEntry (fname);
+        if (real_path != null)
+            entry.ExtraData = ConvertToArray(real_path);
+
+ zip_output.PutNextEntry (entry);
  XmlTextWriter xmlWriter = new XmlTextWriter (zip_output, Encoding.UTF8);
  doc.WriteContentTo (xmlWriter);
  xmlWriter.Flush ();
Index: mono-ecma-css.xsl
===================================================================
--- mono-ecma-css.xsl (revisión: 96411)
+++ mono-ecma-css.xsl (copia de trabajo)
@@ -684,7 +684,7 @@
  <xsl:apply-templates select="summary" mode="notoppara"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]
  </xsl:if>
  </div>
 
@@ -696,7 +696,7 @@
  <xsl:apply-templates select="remarks"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'remarks')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'remarks')}">Edit</a>]
  </xsl:if>
  </div>
  </xsl:if>
Index: mono-ecma.xsl
===================================================================
--- mono-ecma.xsl (revisión: 96411)
+++ mono-ecma.xsl (copia de trabajo)
@@ -717,7 +717,7 @@
  <xsl:apply-templates select="summary" mode="notoppara"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]
  </xsl:if>
  </p>
 
@@ -729,7 +729,7 @@
  <xsl:apply-templates select="remarks"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'remarks')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'remarks')}">Edit</a>]
  </xsl:if>
  </blockquote>
  </xsl:if>
Index: ecma-provider.cs
===================================================================
--- ecma-provider.cs (revisión: 96411)
+++ ecma-provider.cs (copia de trabajo)
@@ -184,6 +184,7 @@
  if (File.Exists (ns_summary_file)) {
  XmlDocument nsSummaryFile = new XmlDocument ();
  nsSummaryFile.Load (ns_summary_file);
+                        namespace_realpath [tn] = ns_summary_file;
 
  XmlNode ns_summary = nsSummaryFile.SelectSingleNode ("Namespace/Docs/summary");
  if (ns_summary != null && ns_summary.InnerText != "To be added." && ns_summary.InnerText != "") {
@@ -291,7 +292,7 @@
  e.AppendChild (copy);
  elements.AppendChild (e);
  }
- hs.PackXml ("xml.summary." + ns, doc);
+ hs.PackXml ("xml.summary." + ns, doc,(string) namespace_realpath[ns]);
  }
 
 
@@ -310,12 +311,13 @@
  summary.AppendChild (nsSummary.CreateElement("summary"));
 
  }
- tree.HelpSource.PackXml ("mastersummary.xml", nsSummary);
+ tree.HelpSource.PackXml ("mastersummary.xml", nsSummary, null);
  }
       
  static Hashtable class_summaries = new Hashtable ();
  static Hashtable namespace_summaries = new Hashtable ();
  static Hashtable namespace_remarks = new Hashtable ();
+ static Hashtable namespace_realpath = new Hashtable ();
  XmlDocument doc;
 
  void PopulateClass (string ns, Node ns_node, string file)
@@ -869,16 +871,16 @@
 
  match_node = ns_node;
  string ns_name = nsurl.Substring (2);
-
- XmlReader summary = GetNamespaceDocument (ns_name);
- if (summary == null)
+            
+            XmlDocument doc = GetHelpXmlWithChanges("xml.summary." + ns_name);
+            if (doc == null)
  return null;
 
  XsltArgumentList args = new XsltArgumentList();
  args.AddExtensionObject("monodoc:///extensions", ExtObject);
  args.AddParam("show", "", "namespace");
  args.AddParam("namespace", "", ns_name);
- string s = Htmlize(new XPathDocument (summary), args);
+ string s = Htmlize(doc, args);
  return BuildHtml (css_ecma_code, s);
 
  }
@@ -1181,10 +1183,12 @@
  return "";
  }
 
- public string EditUrlNamespace (string ns, string section)
+ public string EditUrlNamespace (XPathNodeIterator itr, string ns, string section)
  {
  if (hs is EcmaUncompiledHelpSource)
  return "edit:file:" + Path.Combine(((EcmaUncompiledHelpSource)hs).BasePath, ns + ".xml") + "@/Namespace/Docs/" + section;
+            else if (itr.MoveNext ())
+                return EditingUtils.FormatEditUri(itr.Current.BaseURI, "/elements/" + section);
  return "";
  }
 


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@...
http://lists.ximian.com/mailman/listinfo/mono-docs-list

Re: [PATCH] Fixing namespace edit (#319116)

by Jonathan Pryor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2008-02-22 at 18:08 +0100, Mario Sopena Novales wrote:

> Index: provider.cs
> ===================================================================
> --- provider.cs (revisión: 96411)
> +++ provider.cs (copia de trabajo)
> @@ -609,9 +609,13 @@
>                 }      
>         }
>        
> -       public void PackXml (string fname, XmlDocument doc)
> +       public void PackXml (string fname, XmlDocument doc, string real_path)
>         {
> -               zip_output.PutNextEntry (new ZipEntry (fname));
> +        ZipEntry entry = new ZipEntry (fname);
> +        if (real_path != null)
> +            entry.ExtraData = ConvertToArray(real_path);
> +
> +               zip_output.PutNextEntry (entry);

Please fix your indenting.

> Index: mono-ecma-css.xsl
> ===================================================================
> --- mono-ecma-css.xsl   (revisión: 96411)
> +++ mono-ecma-css.xsl   (copia de trabajo)
> @@ -684,7 +684,7 @@
>                                 <xsl:apply-templates select="summary" mode="notoppara"/>
>                                 <xsl:if test="monodoc:MonoEditing()">
>                                         <xsl:value-of select="' '" />
> -                                       <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
> +                                       [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]

Any particular reason you don't want the '[' and ']' as part of the link
text?  I'd prefer to keep them as part of the link.

> Index: ecma-provider.cs
> ===================================================================
> --- ecma-provider.cs    (revisión: 96411)
> +++ ecma-provider.cs    (copia de trabajo)
> @@ -184,6 +184,7 @@
>                                         if (File.Exists (ns_summary_file)) {
>                                                 XmlDocument nsSummaryFile = new XmlDocument ();
>                                                 nsSummaryFile.Load (ns_summary_file);
> +                        namespace_realpath [tn] = ns_summary_file;

Fix indentation.
                                               

> @@ -869,16 +871,16 @@
>  
>                         match_node = ns_node;
>                         string ns_name = nsurl.Substring (2);
> -                      
> -                       XmlReader summary = GetNamespaceDocument (ns_name);
> -                       if (summary == null)
> +            
> +            XmlDocument doc = GetHelpXmlWithChanges("xml.summary." + ns_name);
> +            if (doc == null)
>                                 return null;

Shouldn't this fall-back to using GetNamspaceDocument() if
GetHelpXmlWithChanges() fails?
 

> @@ -1181,10 +1183,12 @@
>                         return "";
>                 }
>  
> -               public string EditUrlNamespace (string ns, string section)
> +               public string EditUrlNamespace (XPathNodeIterator itr, string ns, string section)
>                 {
>                         if (hs is EcmaUncompiledHelpSource)
>                                 return "edit:file:" + Path.Combine(((EcmaUncompiledHelpSource)hs).BasePath, ns + ".xml") + "@/Namespace/Docs/" + section;
> +            else if (itr.MoveNext ())
> +                return EditingUtils.FormatEditUri(itr.Current.BaseURI, "/elements/" + section);

Indentation.

Thanks,
 - Jon


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@...
http://lists.ximian.com/mailman/listinfo/mono-docs-list

Re: [PATCH] Fixing namespace edit (#319116)

by Mario Sopena Novales-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

   I fixed all the indentation mess. More comments below:

On 22/02/2008, Jonathan Pryor <jonpryor@...> wrote:

> On Fri, 2008-02-22 at 18:08 +0100, Mario Sopena Novales wrote:
>  > Index: provider.cs
>  > ===================================================================
>  > --- provider.cs (revisión: 96411)
>  > +++ provider.cs (copia de trabajo)
>  > @@ -609,9 +609,13 @@
>  >                 }
>  >         }
>  >
>  > -       public void PackXml (string fname, XmlDocument doc)
>  > +       public void PackXml (string fname, XmlDocument doc, string real_path)
>  >         {
>  > -               zip_output.PutNextEntry (new ZipEntry (fname));
>  > +        ZipEntry entry = new ZipEntry (fname);
>  > +        if (real_path != null)
>  > +            entry.ExtraData = ConvertToArray(real_path);
>  > +
>  > +               zip_output.PutNextEntry (entry);
>
>  Please fix your indenting.
>
>  > Index: mono-ecma-css.xsl
>  > ===================================================================
>  > --- mono-ecma-css.xsl   (revisión: 96411)
>  > +++ mono-ecma-css.xsl   (copia de trabajo)
>  > @@ -684,7 +684,7 @@
>  >                                 <xsl:apply-templates select="summary" mode="notoppara"/>
>  >                                 <xsl:if test="monodoc:MonoEditing()">
>  >                                         <xsl:value-of select="' '" />
>  > -                                       <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
>  > +                                       [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]
>
>  Any particular reason you don't want the '[' and ']' as part of the link
>  text?  I'd prefer to keep them as part of the link.
Because the other Edit links are like this, so I though it would be
better to keep all unified.


>
>  > Index: ecma-provider.cs
>  > ===================================================================
>  > --- ecma-provider.cs    (revisión: 96411)
>  > +++ ecma-provider.cs    (copia de trabajo)
>  > @@ -184,6 +184,7 @@
>  >                                         if (File.Exists (ns_summary_file)) {
>  >                                                 XmlDocument nsSummaryFile = new XmlDocument ();
>  >                                                 nsSummaryFile.Load (ns_summary_file);
>  > +                        namespace_realpath [tn] = ns_summary_file;
>
>  Fix indentation.
>
>  > @@ -869,16 +871,16 @@
>  >
>  >                         match_node = ns_node;
>  >                         string ns_name = nsurl.Substring (2);
>  > -
>  > -                       XmlReader summary = GetNamespaceDocument (ns_name);
>  > -                       if (summary == null)
>  > +
>  > +            XmlDocument doc = GetHelpXmlWithChanges("xml.summary." + ns_name);
>  > +            if (doc == null)
>  >                                 return null;
>
>  Shouldn't this fall-back to using GetNamspaceDocument() if
>  GetHelpXmlWithChanges() fails?
Well, the reason is that GetNamespaceDocument calls GetHelpXml() which
is a function copy&pasted to GetHelpXmlWithChanges except for the
later calling one extra method to detect whether there are changes and
applying them. In fact, I think we should remove
GetNamespaceDocument... well, I think the monodoc "library" need a
heavy refactoring because it is a little mess, I just don't find
enough free time to do it, ;-P


>
>  > @@ -1181,10 +1183,12 @@
>  >                         return "";
>  >                 }
>  >
>  > -               public string EditUrlNamespace (string ns, string section)
>  > +               public string EditUrlNamespace (XPathNodeIterator itr, string ns, string section)
>  >                 {
>  >                         if (hs is EcmaUncompiledHelpSource)
>  >                                 return "edit:file:" + Path.Combine(((EcmaUncompiledHelpSource)hs).BasePath, ns + ".xml") + "@/Namespace/Docs/" + section;
>  > +            else if (itr.MoveNext ())
>  > +                return EditingUtils.FormatEditUri(itr.Current.BaseURI, "/elements/" + section);
>
>  Indentation.
>
>  Thanks,
>   - Jon


Thanks,  Mario

[ns.diff]

Index: provider.cs
===================================================================
--- provider.cs (revisión: 96411)
+++ provider.cs (copia de trabajo)
@@ -609,9 +609,13 @@
  }
  }
 
- public void PackXml (string fname, XmlDocument doc)
- {
- zip_output.PutNextEntry (new ZipEntry (fname));
+ public void PackXml (string fname, XmlDocument doc, string real_path)
+ {
+ ZipEntry entry = new ZipEntry (fname);
+ if (real_path != null)
+ entry.ExtraData = ConvertToArray(real_path);
+
+ zip_output.PutNextEntry (entry);
  XmlTextWriter xmlWriter = new XmlTextWriter (zip_output, Encoding.UTF8);
  doc.WriteContentTo (xmlWriter);
  xmlWriter.Flush ();
Index: mono-ecma-css.xsl
===================================================================
--- mono-ecma-css.xsl (revisión: 96411)
+++ mono-ecma-css.xsl (copia de trabajo)
@@ -684,7 +684,7 @@
  <xsl:apply-templates select="summary" mode="notoppara"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]
  </xsl:if>
  </div>
 
@@ -696,7 +696,7 @@
  <xsl:apply-templates select="remarks"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'remarks')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'remarks')}">Edit</a>]
  </xsl:if>
  </div>
  </xsl:if>
Index: mono-ecma.xsl
===================================================================
--- mono-ecma.xsl (revisión: 96411)
+++ mono-ecma.xsl (copia de trabajo)
@@ -717,7 +717,7 @@
  <xsl:apply-templates select="summary" mode="notoppara"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'summary')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'summary')}">Edit</a>]
  </xsl:if>
  </p>
 
@@ -729,7 +729,7 @@
  <xsl:apply-templates select="remarks"/>
  <xsl:if test="monodoc:MonoEditing()">
  <xsl:value-of select="' '" />
- <a href="{monodoc:EditUrlNamespace ($namespace, 'remarks')}">[Edit]</a>
+ [<a href="{monodoc:EditUrlNamespace (., $namespace, 'remarks')}">Edit</a>]
  </xsl:if>
  </blockquote>
  </xsl:if>
Index: ecma-provider.cs
===================================================================
--- ecma-provider.cs (revisión: 96411)
+++ ecma-provider.cs (copia de trabajo)
@@ -184,6 +184,7 @@
  if (File.Exists (ns_summary_file)) {
  XmlDocument nsSummaryFile = new XmlDocument ();
  nsSummaryFile.Load (ns_summary_file);
+ namespace_realpath [tn] = ns_summary_file;
 
  XmlNode ns_summary = nsSummaryFile.SelectSingleNode ("Namespace/Docs/summary");
  if (ns_summary != null && ns_summary.InnerText != "To be added." && ns_summary.InnerText != "") {
@@ -291,7 +292,7 @@
  e.AppendChild (copy);
  elements.AppendChild (e);
  }
- hs.PackXml ("xml.summary." + ns, doc);
+ hs.PackXml ("xml.summary." + ns, doc,(string) namespace_realpath[ns]);
  }
 
 
@@ -310,12 +311,13 @@
  summary.AppendChild (nsSummary.CreateElement("summary"));
 
  }
- tree.HelpSource.PackXml ("mastersummary.xml", nsSummary);
+ tree.HelpSource.PackXml ("mastersummary.xml", nsSummary, null);
  }
       
  static Hashtable class_summaries = new Hashtable ();
  static Hashtable namespace_summaries = new Hashtable ();
  static Hashtable namespace_remarks = new Hashtable ();
+ static Hashtable namespace_realpath = new Hashtable ();
  XmlDocument doc;
 
  void PopulateClass (string ns, Node ns_node, string file)
@@ -870,15 +872,15 @@
  match_node = ns_node;
  string ns_name = nsurl.Substring (2);
 
- XmlReader summary = GetNamespaceDocument (ns_name);
- if (summary == null)
+ XmlDocument doc = GetHelpXmlWithChanges("xml.summary." + ns_name);
+ if (doc == null)
  return null;
 
  XsltArgumentList args = new XsltArgumentList();
  args.AddExtensionObject("monodoc:///extensions", ExtObject);
  args.AddParam("show", "", "namespace");
  args.AddParam("namespace", "", ns_name);
- string s = Htmlize(new XPathDocument (summary), args);
+ string s = Htmlize(doc, args);
  return BuildHtml (css_ecma_code, s);
 
  }
@@ -1181,10 +1183,12 @@
  return "";
  }
 
- public string EditUrlNamespace (string ns, string section)
+ public string EditUrlNamespace (XPathNodeIterator itr, string ns, string section)
  {
  if (hs is EcmaUncompiledHelpSource)
  return "edit:file:" + Path.Combine(((EcmaUncompiledHelpSource)hs).BasePath, ns + ".xml") + "@/Namespace/Docs/" + section;
+ else if (itr.MoveNext ())
+ return EditingUtils.FormatEditUri(itr.Current.BaseURI, "/elements/" + section);
  return "";
  }
 


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@...
http://lists.ximian.com/mailman/listinfo/mono-docs-list