+@@ -146,19 +157,22 @@
+ *
+ * use %module(directors="1") modulename at the start of the
+ * interface file to enable director generation.
+ */
++ String* mod_docstring = NULL;
+ {
+- Node *module = Getattr(n, "module");
+- if (module) {
+- Node *options = Getattr(module, "options");
++ Node *mod = Getattr(n, "module");
++ if (mod) {
++ Node *options = Getattr(mod, "options");
+ if (options) {
+ if (Getattr(options, "directors")) {
+ allow_directors();
+ }
+ if (Getattr(options, "dirprot")) {
+ allow_dirprot();
+ }
++ mod_docstring = Getattr(options, "docstring");
++ package = Getattr(options, "package");
+ }
+ }
+ }
+
+@@ -258,8 +272,13 @@
+ Printv(f_shadow,
+ "# This file is compatible with both classic and new-style classes.\n",
+ NIL);
+ }
++
++ if (mod_docstring && Len(mod_docstring)) {
++ Printv(f_shadow, "\n\"\"\"\n", mod_docstring, "\n\"\"\"\n", NIL);
++ Delete(mod_docstring); mod_docstring = NULL;
++ }
+
+ Printf(f_shadow,"\nimport %s\n\n", module);
+
+ if (! modern) {
+@@ -382,9 +401,28 @@
+ virtual int importDirective(Node *n) {
+ if (shadow) {
+ String *modname = Getattr(n,"module");
+ if (modname) {
+- Printf(f_shadow,"import %s\n", modname);
++ Printf(f_shadow,"import ");
++
++ // Find the module node for this imported module. It should be the
++ // first child but search just in case.
++ Node* mod = firstChild(n);
++ while (mod && Strcmp(nodeType(mod), "module") != 0)
++ mod = nextSibling(mod);
++
++ // Is the imported module in another package? (IOW, does it use the
++ // %module(package="name") option and it's different than the package
++ // of this module.)
++ Node *options = Getattr(mod, "options");
++ if (options && Getattr(options, "package")) {
++ String* pkg = Getattr(options, "package");
++ if (!package || Strcmp(pkg, package) != 0)
++ Printf(f_shadow, "%s.", Getattr(options, "package"));
++ }
++
++ // finally, output the name of the imported module
++ Printf(f_shadow, "%s\n", modname);
+ }
+ }
+ return Language::importDirective(n);
+ }
+@@ -417,17 +455,25 @@